observable-mixin
Just observe
Mixin that makes your types observable without exposing emitter.
npm install --save observable-mixin
Usage
observable-mixin
brings 1 method:
subscribe(eventName: String, handler: Function, [once: Boolean]): Function
returns a function that unsubscribes a given listener
The mixin comes as a factory function i.e. in order to get mixin it needs to invoke exported function. It is done intentionally in order to be able to pass any kind of implementation of EventEmitter.
; ; ; ; const FIELDS = emitter: Symbol'emitter' name: Symbol'name' ; const Person = ;
; const person = 'Mike Wazowski'; const unsubscribe = person; personname'James P. Sullivan'; // Person's name was changed to 'James P. Sullivan' ; personname'Randall Boggs'; // Nothing
Mixin supports once
subscription:
; const person = 'Mike Wazowski'; person; personname'James P. Sullivan'; // Person's name was changed to 'James P. Sullivan' personname'Randall Boggs'; // Nothing