Open zozozo opened 6 years ago
Hi @zozozo ,
The current usage scenario is that nodejs-mobile runs in a background thread and the UI must use some sort of communication mechanism to send/receive data from nodejs.
Integrating nodejs-mobile into the WebView would be a big challenge, since the WebView on each platform would be running a different JavaScript engine than nodejs-mobile (V8 on Android and ChakraCore on iOS), plus nodejs uses a libuv event loop at its core, which would also be different than the event loop in the WebView. This makes the "require
Node modules from JavaScript loaded within WebView" scenario very challenging at best, or unfeasible at worst.
One way to use this library with the WebView on each platform would be to look into how the Cordova plugin is implementing the communication channel to send messages between Cordova and nodejs-mobile and try to implement it on your specific WebView scenario. Another way would be to use another communication channel that would be normally used between client and server, such as Websockets, to communicate between the UI Javascript and the nodejs-mobile server.
I hope this answers your question.
Thank you for the detailed response. It was very clear.
How does one use this awesome build with WebView without Cordova on Android & iOS?
If the app only requires features from the browser + Node.js features; Cordova with nodejs-mobile-cordova is kind of an overkill.
Is it possible to
require
Node modules from JavaScript loaded within WebView? If not, what must be done in order to achieve this?Thank you