mobx-observed
v1.0.0-alpha.15
Published
This library provides a decorator version of MobX onBecomeObserved and a decorator to make it more convenient.
Downloads
16
Readme
Overview
This library provides a decorator version of MobX onBecomeObserved and a decorator to make it more convenient.
compatibility
Supports MobX5 decorator, MobX6 decorator, and MobX6 annotation. MobX6 decorator requires initialization with makeObservable / makeAutoObservable.
APIs
onBecomeObserved
@onBecomeObserved(function(this:any){
// // onBecomeObserved
return () => {
// onBecomeUnobserved
};
}, function(this:any){
// onBecomeUnobserved
})
observed
@observed(
changed: ({newValue, oldValue}) => {})
enter: ({oldValue}) => {})
leave: ({oldValue}) => {})
)
observed.async
@observed.async(
changed: ({newValue, oldValue}, setter) => {})
enter: ({oldValue}, setter) => {})
leave: ({oldValue}, setter) => {})
)