A photo manager for VRChat.
1export enum ViewState{ 2 SETTINGS, 3 PHOTO_LIST, 4 PHOTO_VIEWER 5} 6 7export class ViewManager{ 8 private _state: ViewState = ViewState.PHOTO_LIST; 9 private _eventListeners: { from: ViewState, to: ViewState, cb: () => void }[] = []; 10 11 public ChangeState( state: ViewState ){ 12 console.log('From: ' + this._state + ' To: ' + state); 13 this._eventListeners.filter(x => x.from === this._state && x.to === state).forEach(c => c.cb()); 14 this._state = state; 15 } 16 17 public GetState(){ return this._state; } 18 19 public OnStateTransition( from: ViewState, to: ViewState, cb: () => void ){ 20 this._eventListeners.push({ from, to, cb }); 21 } 22}