-
Notifications
You must be signed in to change notification settings - Fork 103
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
Provide a way for MyMoneroCoreBridge functions to be accessed via both old sync and new JS async methods #80
Comments
Do you mean all methods are async? It's going to break a lot of old apps. I use a hack in my code for now
|
Hey @gutenye I totally agree re: breaking other apps. That's why I think personally we need to find a way to support both sync and async. It doesn't seem to make sense to me to require everyone to upgrade to something like webpack + babel to down-compile. There isn't a way to load the WASM module synchronously, according to my investigations. The sort of hack you're using could work but of course it could end up racing. What I do is execute my code within the promise fulfillment. That's either within a particular function which is already expected to execute asynchronously (such as with some callback) or it means wrapping the initialization of the app in the promise resolve and then passing the returned monero_utils instance to the rest of the app via something like dependency injection. |
There is no way to use this library on React Native without an async API. Basically, the React Native Javascript engine talks to native modules using a local network connection. Every method call into native code gets sent over a WebSocket or similar platform-specific connection. The native thread processes the call and send the results back over the same connection. This means all calls into native code must be async, since they are secretly network calls. The other option, using asm.js, obviously won't perform as well as native code. I understand that the existing sync API needs to remain for legacy purposes. Plus, WASM doesn't have the same limitations are React Native. Therefore, it seems like this library will simply have to ship two separate API's. |
Going async-only would require some pretty big changes to the MyMonero app... and it would cut off lots of other websites which rely on the synchronous methods, so I hope this can start a discussion about whether people feel comfortable moving to async-only.
For the async version, we can get rid of the monero_utils interface requirement to wait for module load first, since we can put the async wait on self.Module within each method.
The text was updated successfully, but these errors were encountered: