import { makeObservable , observable } from 'mobx' ; import type { IDatabaseDataAction , IDatabaseDataActionClass , IDatabaseDataActionInterface } from './IDatabaseDataAction' ; import type { IDatabaseDataResult } from './IDatabaseDataResult' ; import type { IDatabaseDataSource } from './IDatabaseDataSource' ; export abstract class DatabaseDataAction < TOptions , TResult extends IDatabaseDataResult > implements IDatabaseDataAction < TOptions , TResult > { result : TResult ; get resultIndex ( ) : number { return this . source . results . indexOf ( this . result ) ; } readonly source : IDatabaseDataSource < TOptions , TResult > ; constructor ( source , result ) { this . result = result ; this . source = source ; makeObservable ( this , { result : observable . ref , } ) ; } updateResult ( result ) { this . result = result ; } afterResultUpdate ( ) { } tryGetAction < T extends IDatabaseDataAction < TOptions , TResult > > ( action ) { return this . source . actions . tryGet ( this . result , action ) ; } getAction < T extends IDatabaseDataAction < TOptions , TResult > > ( action ) { return this . source . actions . get ( this . result , action ) ; } getActionImplementation < T extends IDatabaseDataAction < TOptions , TResult > > ( action ) { return this . source . actions . getImplementation ( this . result , action ) ; } dispose ( ) { } } export function isDatabaseDataAction ( action ) { return action . prototype instanceof DatabaseDataAction ; }