snappymail/dev/Knoin/AbstractScreen.js

54 lines
847 B
JavaScript
Raw Normal View History

2019-07-05 03:19:24 +08:00
export class AbstractScreen {
2016-09-10 06:38:16 +08:00
oCross = null;
sScreenName;
aViewModels;
2019-07-05 03:19:24 +08:00
constructor(screenName, viewModels = []) {
2016-07-07 07:11:13 +08:00
this.sScreenName = screenName;
this.aViewModels = Array.isArray(viewModels) ? viewModels : [];
2016-07-07 07:11:13 +08:00
}
/**
* @returns {Array}
*/
viewModels() {
return this.aViewModels;
}
/**
* @returns {string}
*/
screenName() {
return this.sScreenName;
}
/**
* @returns {?Array)}
*/
routes() {
return null;
}
/**
* @returns {?Object}
*/
2020-10-02 18:40:33 +08:00
get __cross() {
2016-07-07 07:11:13 +08:00
return this.oCross;
}
/**
* @returns {void}
*/
__start() {
const routes = this.routes();
2020-09-04 23:07:35 +08:00
if (Array.isNotEmpty(routes)) {
2020-09-23 20:44:46 +08:00
let route = new Crossroads(),
fMatcher = (this.onRoute || (()=>{})).bind(this);
routes.forEach(item => item && route && (route.addRoute(item[0], fMatcher).rules = item[1]));
2016-07-07 07:11:13 +08:00
this.oCross = route;
}
}
}