Custom Decorators
Create custom decorators to control the behavior of sink functions.
@debounce
import _debounce from 'lodash/debounce';
export function debounce(wait: number, option?: any) {
return function (target: any, name: string, descriptor: PropertyDescriptor) {
descriptor.value = _debounce(descriptor.value, wait, option);
}
}import { debounce } from './debounce';
class CounterSink extends React.Component {
...
@debounce(300)
@effect
update(state: any) {
this.state = state;
}
}@throttle
Last updated