##// END OF EJS Templates
linting
linting

File last commit:

r107:e59104632d14 default
r108:d644dced936e default
Show More
MainModel.ts
33 lines | 824 B | video/mp2t | TypeScriptLexer
cin
Working on WatchForRendition
r107 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() { }
}