Screens

General rules

  • Only screens are allowed to use services,
  • Only screens can route to another screen

Method prepareData

General rules

preparedata is an asynchronous method that returns the data. Data will be binded later to the children. prepareData should only get the data and that’s all ! (forbidden to do anything with the children) (example below)

Examples

WRONG:

prepareData: function(context) {
    this.categoryId = context.categoryId; // WRONG place
    return this.vodService.getContents(context.categoryId)
        .then((contents) => this.vodRail.setData(contents)); // WRONG place
}

GOOD:

prepareData: function(context) {
    return this.vodService.getContents(context.categoryId);
},
connectData: function(context) {
    this.vodRail.setData(this.data); // GOOD place
    this.categoryId = context.categoryId; // GOOD place
}

Method connectData

General rules

  • Connect the data prepared by prepareData to the view,
  • Do not play with views (states, focus etc…) in connectData. Use _getChildToFocus, beforeShow or onScreenReady. (example below)

Examples

Do not play with views (states, focus…) in connectData:

WRONG:

connectData: function(context) {
    this.vodRail.focus(); // WRONG place
}

GOOD:

_getChildToFocus: function() {
    return this.vodRail; // GOOD place
}