-
Notifications
You must be signed in to change notification settings - Fork 0
Hello World App
In this tutorial, I will quickly introduce you to the API which you will need to create Apps for the AdoMado Apps Platform.
A few quick points to remember, before planning your App
- jQuery is always available to your app as $j
- Your App exposes a set of callbacks which are called as and when a user interacts with your App
- The App is run within the scope of a self executing function, hence you are free to define any variables in your namespace.
- Your scope contains an object - config - which you can use to access the API object instance
- Each App is accompanied by a manifest file which defines rules about how the Apps Platform should load your App
Instead of making you read the API documentation, lets start straight by creating the ubiquitous Hello World App. The objective will be to quickly introduce you to the API.
(function(config) {
var HelloWorld = { // Start
init : function() {
config.api.log("Hello, World!");
},
options : function() {
config.api.log("Options!");
},
contextAction : function() {
config.api.log("Context action invoked");
}
}; // HelloWorld End
config.api.callbacks({
init : HelloWorld.init,
options : HelloWorld.options,
contextAction : HelloWorld.contextAction
});
})({
api : new IJAppApi.v1({appId : "__APP_ID__"})
});
As you can see, the Apps's code is just a collection of callbacks, namely - HelloWorld.init, HelloWorld.options and HelloWorld.contextAction. These callbacks are connected to the API using the config.api.callbacks function.
The App is scoped by a self executing anonymous function, which in its entirety looks like...
(function(config) {
// your app code goes here...
})({
api : new IJAppApi.v1({appId : "__APP_ID__"})
});
If this looks a bit too intimidating, this is just the following implementation
(function(args) {})(args);
We define an anonymous function and immediately execute it. Any arguments be passed onto your anonymous function as willed. Read more about this technique.