0.0.104 • Published 5 years ago
@anic/observer v0.0.104
@anic/observer
Observer
Install
$ yarn add @anic/observer
Usage
import observer from '@anic/observer';
// create
const { subscribe, notify } = observer();
// subscribe
const unsubscribe = subscribe((...args) => console.log(args));
// unsubscribe
unsubscribe();
// notify
notify(1, 2, 3);
Class: Observer
subscribe(listener: Function): Function
add listener, return unsubscribe
handler.
notify(...args: any[]): Promise
notify observer, return the Promise
for all the subscribe handler resolved.