How to load a dependent viewer module
I wrote a module that has a dependency on the Workflow module. Since the introduction of module lazy loading, this no longer works, e.g. this.app.getWorkflowActivityDispatcher() returns null. The first run of any workflow triggers loading of the Workflow module, and then my module works again.
How can I force loading of a dependent module? I tried to add "require": "Mapping/Modules/Workflow/WorkflowViewModel" to my module's configuration, but that does not seem to do anything.
I could probably set async to false for the Workflow module, but I'd prefer to defer loading it until my module actually needs it. So, if it can be done from code, that would be perfect.
0
-
To answer my own question, I found the Application.awaitModulesForCommand() in the AMD type definition file. This is exactly what I needed. 0 -
Hi,
I had the same problem when updating to the latest viewer. Had custom modules and this.app.getWorkflowActivityDispatcher() stopped returning a value instead returning NULL. Tried in desktop.json to use deferLoading: false for those modules but to no avail.
Could you give me a bit more detail where you used the Application.awaitModulesForCommand()?
Thanks in advance.0 -
You need to call it when calling a method from another module. In your case, you probable need to wait for the Workflow module to be loaded. From the top of my head: // Untested: this.app.awaitModules(["Workflow"]).then(() => { this.app.getWorkflowActivityDispatcher(); });0 -
This of course causes a crash in essentials.bundle.js on:
"geocortex/workflow/WorkflowControllerProxy": function ()
o = n.encodeJson(dojo.mixin({ f: "json" }, o)), null != t && (t.isBusy = !0), t.webRequestBegin(s, e)
The "t" is the dispatchhandler that is null.
Hence why I wanted to know if the Application.awaitModulesForCommand() solved this for you.
Thanks again0 -
Thanks for the answer.
I'm going to try your suggestion. My fix so far has been setting the "deferLoading" on the Workflow Module in Desktop.json to "false".
This cleared the problem.
But of course your suggestion would be more resource load "cheaper".0 -
Yes, that was what fixed it for me. Note that if you use awaitModulesForCommand(), you'd have to pass the name of a command (e.g. 'RunWorkflowById'), and with awaitModules() the name(s) of one or more modules.
I haven't seen the error you posted.0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
6 kommentarer