import { StateAction } from '../types' ; import { CountableSubject } from './CountableSubject' ; import { StatedBeanContainer } from './StatedBeanContainer' ; export class BeanWrapper < T > { state$ : CountableSubject < StateAction < T > > = new CountableSubject ( ) ; constructor ( private readonly _container , private readonly _beanName ) { } get beanObserver ( ) { return this . _container . getNamedObserver < T > ( this . _beanName ) ; } get beanDefinition ( ) { return this . beanObserver ! . beanDefinition ; } get beanMeta ( ) { return this . beanDefinition . beanMeta ; } forceUpdate ( field ) { const fieldMeta = ( this . beanMeta . statedFields || [ ] ) . find ( f => f . name === field ) ; if ( fieldMeta !== undefined ) { this . beanObserver ! . publishStateAction ( fieldMeta , this . beanObserver ! . proxy [ field ] ) ; } } }