Multiple calls to initRDKitModule #437
-
Reposting from #436 Firstly, thanks a lot for all the work that's gone into this project. It's really nice to have the rdkit functionality in the browser. I have a (hopefully) basic question, which might be answered in the docs somewhere but I couldn't find it. If I have a webapp in which multiple independent parts might require rdkit, what's the convention around calls to initRDKitModule. Each call seems to trigger a fetch of the wasm code, so I'm guessing its setting up a new instance per-call. I can easily define some convention within my app whereby the promise (return value of initRDKitModule) is saved on some global object or shared state, but I'm aware I might be missing something here. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@fredludlow Hi Fred, as you already figured out, every time you call |
Beta Was this translation helpful? Give feedback.
-
No -
To configure the size of the emscripten heap, you may use |
Beta Was this translation helpful? Give feedback.
@fredludlow Hi Fred, as you already figured out, every time you call
initRDKitModule()
a new instance of the module will be created.You may take a look at how the
rdkit-structure-renderer
package avoids multiple instantiations:Renderer.init()
is safe to call multiple times, as it will only instantiate the RDKit module once.You might as well find convenient to use
rdkit-structure-renderer
(it is a vanilla JS package with very few dependencies other than MinimalLib itself) rather than implementing the logic again in your app.Note that
rdkit-structure-renderer
does not depend onrdkit-js
- it bundles its own version of MinimalLib, which may include additional functionality compared tord…