Gaia/System/NewModule: Difference between revisions

no edit summary
(Created page with "If you want to add a new functionality, a.k.a., a new script or a new module into system app after bug 1094759, please read this. == If you want to use BaseModule == Great! I...")
 
No edit summary
Line 4: Line 4:
== If you want to use BaseModule ==
== If you want to use BaseModule ==
Great! It's providing a promise based start procedure and what you need to do.
Great! It's providing a promise based start procedure and what you need to do.
```js
 
var NewModule = function() {};
  var NewModule = function() {};
BaseModule.create(NewModule, {
  BaseModule.create(NewModule, {
  name: 'NewModule',
    name: 'NewModule',
  _start: function() {
    _start: function() {
    // return a promise if your start progress involves some asynchronous operation
      // return a promise if your start progress involves some asynchronous operation
    // return null or do not return, then we will unblock your module from the starting process right away once
      // return null or do not return, then we will unblock your module from the starting process right away once
    // yourModule.start() is called
      // yourModule.start() is called
    // BaseModule has a native start() function to process not only your own starting (this._start()) but also the child
      // BaseModule has a native start() function to process not only your own starting (this._start()) but also the child
    // module's start() function. The whole starting process will be resolved only when all the children's start process
      // module's start() function. The whole starting process will be resolved only when all the children's start process
    // is resolved.
      // is resolved.
  }
    }
});
  });
```


== If you don't want to use BaseModule ==
== If you don't want to use BaseModule ==
It's okay. But you have to provide this interface for us:
It's okay. But you have to provide this interface for us:


```js
  var NewModule = {
var NewModule = {
    start: function() {
  start: function() {
      // return a promise if your start progress involves some asynchronous operation
    // return a promise if your start progress involves some asynchronous operation
      // return null or do not return, then we will unblock your module from the starting process right away once
    // return null or do not return, then we will unblock your module from the starting process right away once
      // yourModule.start() is called
    // yourModule.start() is called
    }
  }
  };
};
```


== No matter what you choose to go ==
== No matter what you choose to go ==
Confirmed users
401

edits