Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more samples in README #289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add more samples in README #289

wants to merge 1 commit into from

Conversation

Laisky
Copy link

@Laisky Laisky commented Feb 22, 2022

add two useful samples in readme

  1. call go func in js and return some values
  2. resolve js promise in go

README.md Outdated
```

### Resolve JavaScript Promise in Go
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this example changed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this example changed?

add sample return real value to js

@genevieve
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants