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

Documentation #21

Open
MulverineX opened this issue Apr 26, 2024 · 6 comments
Open

Documentation #21

MulverineX opened this issue Apr 26, 2024 · 6 comments
Labels
Milestone

Comments

@MulverineX
Copy link
Collaborator

No description provided.

@MulverineX MulverineX added this to the v0.3.0 milestone Apr 26, 2024
@mochar
Copy link

mochar commented May 7, 2024

Is there an example we can look at in the meantime?

@mochar
Copy link

mochar commented May 21, 2024

@MulverineX From these examples it is not clear how one can get the results back from javascript calls. Perhaps with MercuryDispatcher but the workings of it I did not manage to figure out. Any help is appreciated

@MulverineX
Copy link
Collaborator Author

MulverineX commented May 21, 2024

@mochar

final result = evaluateScripts('path.to.function("bar")')`

This is how Flutter land issues events to JS land and receives a response back synchronously


controller.context.dispatcher?.subscribe('example', (args) {
            evaluateScripts(`${args[0]['callback']}('hellooooo')`)
          });
let baz = (foo) => console.log(foo)

mercury.dispatcher.dispatch('example', { callback: `baz`});

This is how JS land issues events to Flutter land and receives a response back with a callback (there is no synchronous response mechanism)

@MulverineX
Copy link
Collaborator Author

MulverineX commented May 21, 2024

If you would like to have synchronous response from Dart somehow for simpler code, you're welcome to create a feature request issue for that, just keep in mind it won't be a priority, it's more likely it'll be implemented if we receive a PR. Remember that you can wrap callback systems like this with a Promise to make it cleaner in asynchronous functions.

@mochar
Copy link

mochar commented May 21, 2024

@MulverineX Thanks a lot!!

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

No branches or pull requests

2 participants