Nested System.import in Javascript

66 Views Asked by At

I am struggling with Javascript and System.import

I have the following and further Methods inside

System.import("frm/core").then(function(core) {
    core.companionScript("something", function ($element, options) {
    "use strict";

Now I need to integrate another import System.import("frm/mod/messages") containing a method addMessages

I tried the following

System.import("frm/core").then(function(core) {
    System.import("frm/mod/messages").then(function() {

    core.companionScript("something", function ($element, options) {
    "use strict";

further down in the existing code I try to invoke the addMessage but It does not work at all. It always fails with an error that the method ist not present.

This is what I try to do in side an existing function

                 function doSomething(password){
                 ……
                     if(condition) {
                         addMEssages("p1", "p2", {errors : ["errKEy"]});
                               }
                  ……
                 }
0

There are 0 best solutions below