1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/ReactNativeClient/lib/services/NavService.js

34 lines
676 B
JavaScript
Raw Normal View History

class NavService {
static async go(routeName) {
if (this.handlers_.length) {
let r = await this.handlers_[this.handlers_.length - 1]();
if (r) return r;
}
this.dispatch({
2018-03-09 19:49:35 +02:00
type: "NAV_GO",
routeName: routeName,
2018-03-09 19:49:35 +02:00
});
}
static addHandler(handler) {
for (let i = this.handlers_.length - 1; i >= 0; i--) {
const h = this.handlers_[i];
if (h === handler) return;
}
return this.handlers_.push(handler);
}
static removeHandler(hanlder) {
for (let i = this.handlers_.length - 1; i >= 0; i--) {
const h = this.handlers_[i];
if (h === hanlder) this.handlers_.splice(i, 1);
}
}
}
NavService.handlers_ = [];
2018-03-09 19:49:35 +02:00
module.exports = NavService;