import { makeAutoObservable , makeObservable , observable } from 'mobx' ; import { StorageState } from './StorageState' ; export class MappingState < T > { currentId : any ; map : { [ key ] : T ; } ; constructor ( args ) { Object . assign ( this , args ) ; makeAutoObservable ( this ) ; } get current ( ) : T { return this . map [ this . currentId ] ; } setCurrentId ( val ) { this . currentId = val ; } } export class MappingStorageState < T > { currentId : StorageState < any > ; map : { [ key ] : T ; } ; constructor ( args ) { Object . assign ( this , args ) ; makeAutoObservable ( this ) ; } get current ( ) : T { return this . map [ this . currentId . value ] ; } setCurrentId ( val ) { this . currentId . save ( val ) ; } } export class DynamicMappingState < T > { map : { [ key ] : T ; } ; getId : Function ; constructor ( args ) { Object . assign ( this , args ) ; makeAutoObservable ( this ) ; } get current ( ) : T { return this . map [ this . getId ( ) ] ; } }