##// END OF EJS Templates
linting
linting

File last commit:

r107:e59104632d14 default
r109:4a375b9c654a default
Show More
MainModel.ts
33 lines | 824 B | video/mp2t | TypeScriptLexer
import { BehaviorSubject, Observer, Unsubscribable, Subscribable } from "rxjs";
import { IDestroyable} from "@implab/core-amd/interfaces"
interface State {
color: string;
label: string;
current: number;
max: number;
}
export default class MainModel implements IDestroyable {
private readonly _state: BehaviorSubject<State>;
constructor(initialState: State) {
this._state = new BehaviorSubject(initialState);
}
getState() {
return this._state.getValue();
}
subscribe(observer: Partial<Observer<State>>): Unsubscribable {
return this._state.subscribe(observer);
}
protected dispatch(command: Partial<State>) {
const state = this.getState();
this._state.next({...state, ... command});
}
load() { }
destroy() { }
}