This documents the full API of Motion Corporation App object.
<!-- Import Motion Corporation services --> <script type="text/javascript" src="http://www.mcorp.no/lib/mcorp-2.0.js"></script>
var APPID = "your_app_id_goes_here"; var app = MCorp.app(APPID); app.run = function () { console.log(app.motions["MOTION_NAME_GOES_HERE"].query()); }; app.init();
run() is invoked when all the motions are ready to use. Application specific code should be kicked off from this method.
init() starts app initialisation process.
app.motions is a dictory containing motions. Use motion names as key.
The App object has its own readystate property
app.STATE = Object.freeze({ INIT: "init", CTX: "context", OPEN: "open", CLOSED: "closed" }); app.readyState // getter app.on("readystatechange", handler); // example if (app.readyState === app.STATE["OPEN"]) { // app ready to use }
run() is invoked when app reaches the OPEN state.
In CTX state, motion objects are available in app.motions, but they are not ready to use at this point. Instead of waiting for the run method to execute, it is possible to start earlier in the CTX state.