timo18146
timo18146

Reputation: 75

CXJS How can I start the Apploop from global scope when integrating with existing webapp?

I have the following Problem. A webapp starts with index.html which is the starting point of the cxjs app. But this is within a Framework (M-Files UX API). The Framework calls a function in global scope (OnNewDashboard()) and injects an api and data which is needed by my cxjs-app. So, i need to start the app-loop in this function in global scope.

How can I do this?

Otherwise i must have a user interaction first to be able to access api and data of the framework, which is not good for me as i want to show data from the framework directly on startup.

thanks

Upvotes: 0

Views: 46

Answers (1)

timo18146
timo18146

Reputation: 75

I actually have not found a solution yet to usefully mix ecmascript 6 text/b abel and 5 text/javascript (see original question) while building a new frontend for an old webapp. but what i figured out was, that you can use visibility of child components to wait for a certain object being injected in the global scope. as onInit in Controller won't be executed before visibility is true, this is a workaround. Marco, do you have better way? example:

export class myController extends Controller
{


   onInit(){

       waitforData();
       function waitforData() {

           if (myGlobalExternalDataObject != undefined)
           {
               dashboardStore.set("$SpecialComponent.visible", true);
               dashboardStore.set("$load.visible", false);

               return;
           }
           setTimeout(function () {

               waitforData();
           }, 200);

       }
   }
}
export default <cx>
    <SpecialComponent/>
   <h2 putInto="header" visible={{bind: "$load.visible", defaultValue: true}} >
       Loading... please wait.
   </h2>
   <Section visible={{bind: "$load.visible", defaultValue: true}} mod="well" controller={myController}>
      <p ws >
          Loading... please wait.
      </p>



   </Section>
</cx>

Upvotes: 0

Related Questions