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

Make it work in Node #3

Open
yoshuawuyts opened this issue Nov 27, 2017 · 2 comments
Open

Make it work in Node #3

yoshuawuyts opened this issue Nov 27, 2017 · 2 comments

Comments

@yoshuawuyts
Copy link
Member

Currently if you require rustify for use in Node, it'll do nothing. By using lib/rustify we can make it behave similarly go Sheetify & Glslify.

@goto-bus-stop
Copy link
Member

I think calling lib/rustify to get the same behaviour in Node might be difficult because it is asynchronous, while the rust`` template tag is 'synchronous' (once compiled through rustify). maybe i'm missing something.

#4 would help with this actually because we could return a Promise that does lib/rustify and then instantiates the WebAssembly module.

But, maybe you don't always want a webassembly module instantiated immediately, instead waiting for some event to instantiate it, so idk what's better.

@yoshuawuyts
Copy link
Member Author

@goto-bus-stop was thinking the same.


But, maybe you don't always want a webassembly module instantiated immediately, instead waiting for some event to instantiate it, so idk what's better.

This should work for async initialization; it's a single step instead of two, is all.

emitter.on('some-event', async () => {
  var mod = await rustify('./add')
  console.log(mod.add_one(1))
})

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

No branches or pull requests

2 participants