Conversation
README.md
Outdated
| fmt.Println(ret) // Output: 3 | ||
| ``` | ||
|
|
||
| ### Resolve JavaScript Promise in Go |
There was a problem hiding this comment.
This example isn't resolving the promise in Go, it is just getting the result.
| printfn := v8.NewFunctionTemplate(iso, func(info *v8.FunctionCallbackInfo) *v8.Value { | ||
| fmt.Printf("%v", info.Args()) // when the JS function is called this Go callback will execute | ||
| return nil // you can return a value back to the JS caller if required | ||
| addFn := v8.NewFunctionTemplate(iso, func(info *v8.FunctionCallbackInfo) *v8.Value { |
There was a problem hiding this comment.
Why was this example changed?
There was a problem hiding this comment.
Why was this example changed?
add sample return real value to js
|
I wonder if it's more practical in the long term to keep the examples in the readme minimal. The tests cover almost all of the common usecases including returning a value in the function template, handling the arguments to a function, and getting the returned val as a promise. The benefit of leaning on tests is that they have to compile and work for the code on a given commit (in order to pass CI) so the tests will reflect the expected usage of the code. Markdown can more easily get out of date. |
add two useful samples in readme