12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import RoutingSystem from './RoutingSystem.js';
- import ViewSystem, { View } from './ViewSystem.js';
- import ModuleSystem from './ModuleSystem.js';
- import Modules from '../../modules';
- import EventSystem from './EventSystem';
- import * as Font from 'expo-font';
- export default class ActionSystem {
- constructor(CS) {
- // TODO -- Make correct Initialization
- this.CoreSystem = CS;
- this.EventSystem = new EventSystem();
-
- this.events = [...ActionSystem.Actions];
- this._disabled = false;
- this.setupEvents();
- }
- setupEvents() {
- this.events.map((Action) => {
- this.EventSystem.on(Action.id, (d) => this.dispatch(Action, d));
- });
- }
-
- dispatch(Action, data) {
- return !this._disabled && new Action(this.CoreSystem).run(data)
- }
- disable() {this._disabled = true;}
- enable() {this._disabled = false;}
- toggle() {this._disabled = !this._disabled;}
- createAction(action) {
- if (!action.type) return;
- this.EventSystem.emit(action.type, action.data);
- }
- onUpdate(fn) {this._onUpdate = fn;}
- forceUpdate() {
- this._onUpdate && this._onUpdate();
- }
- }
- export class RouteAction {
- constructor(CS) {
- this.CoreSystem = CS;
- }
- run(data) {
- let {
- route
- } = data;
- if(route)
- this.CoreSystem.goto(route);
- }
- }
- RouteAction.id = "changeRoute";
- ActionSystem.RouteAction = RouteAction;
- ActionSystem.Actions = [
- RouteAction
- ];
|