Hi @pconkie,
When an app is opened with some data - or options - it is available from instantiation as it may be required to tell the app how to set up, where to deeplink to, etc. This is done in the form of an object that is assigned to the prototype scope - this.options
Consider the following example:
// package/widget/48F1...AB73/widget.js
FrogOS.openApp('7C974713200486AFDC475F8BD94B0000FD3A143C6506D1A6', {
foo: 'bar'
});
// package/application/7C97...D1A6/production.js
Com.Frog.Controllers.Application.extend('7C974713200486AFDC475F8BD94B0000FD3A143C6506D1A6.Controllers.Core', {
defaults: {
foo: 'baz'
}
}, {
packageID: '7C974713200486AFDC475F8BD94B0000FD3A143C6506D1A6',
init: function() {
this.main();
},
update: function(options) {
this._super(options);
this.main();
},
main: function() {
this.render();
},
render: function() {
this.element.html(
this.view('main.ejs', { title: this.options.foo }) // renders out <h1>Bar</h1>
);
}
});
You open your app by passing the package id into FrogOS.openApp as the first param, your data is the second param. Your app will then open/focus and FrogOS will set the apps options to match/include the data passed in. When opening the app, this.options is set to the contents of the defaults object in the static object; which is then overridden by the data passed in. When focusing the application (calling openApp when there is already one open) your entry point is the update method. this._super(options) merges the any new data with the existing this.options.
In this example:
we started with a default of this.options.foo = 'baz'.
We initialised with a value of 'bar' so this replaced 'baz' as this.options.foo = 'bar'.
If we tried to open the application again, this time with a different value, 'bar' would be overwritten by that value.
There are some complications that you may experience depending how complex this setup gets, but usually you should be fine.
~ Chris