How to pass variables between custom modules
We have an application that, like the HTML5 viewer in general, is composed of several custom modules which are loaded when the viewer initializes (the modules are added to the desktop.json.js file). Each of the modules needs to pass information to other modules in the application. Is there a way to pass objects between modules? If it is not possible to pass things between modules, is it possible to at least pass objects between view models (we could combine the modules into a single module with multiple views). I looked at the SDK samples but didn't see anything that touched on this topic.
If anyone has an example (typescript preferably) showing how to do this, I'd appreciate seeing it.
Peter.
-
My input may not be the correct, but this is what I try to do.
My understanding about a GVH module is that it is supposed to be independant, and the time to load up the module is not fixed (it looks racing the GVH loads the configured modules). Therfore it is not a good idea to assume the dependant module is exisiting even though you can access it from the other module to get the object from another module.
I am not sure what kind of information configured one module is suppsed to be shared with the others.
If you were you if there are big configuration information, I will try to create one workflow which read the configured file (either Json or xml), and execute the workflow from each of your custom module and get the serialized object of the configuration, and put it to the cache object so that you don't need to execute the workflow unnessary if you already have the object.
I have not tried this idea though yet. But just thought you may try.
Munhwan (aliased as Moon-One)
0 -
Munhwan brings up good points about the race conditions in loading modules and why they need to be self contained. We do have a few different ways to facilitate communication between modules however. While they do not support return values, Commands and Events are ways to pass information and notifications between module boundaries. See the SDK section 'Commands and Events' for more information on how to implement these.
-Kevin
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
2 Kommentare