angular-tiny-eventemitter
angular-tiny-eventemitter copied to clipboard
What is the this.value for?
Hi, could you please explain why do you need the this.value
from the readme.
You don't. Just use it on any service. Anything in MyType
is an example, replace it with what you need.
Sorry for the confusion!
Thanks, it's clear, that it is just a demo, but maybe it's a useful feature? How could I make use of it? Maybe this is possible?
var ev1 = new MyType(1);
var ev2 = new MyType(2);
var cb = function() { /* how to access this.value (1, 2) here */ }; //
ev1.on('event', cb)
ev2.on('event', cb)
ev1.emit('event')
ev2.emit('event')
Or would you suggest to use it like this:
...
var cb = function(value) { console.log(value) };
...
ev1.emit('event', ev1.value)
ev2.emit('event', ev2.value)
Heh, hadn't considered that possibility.
What you could do is to change this line: https://github.com/rubenv/angular-tiny-eventemitter/blob/a6ef4f0e5d84df7eb2650bcbfc0b29df051e5696/src/tiny-eventemitter.js#L76
Replace null
with this
. That will allow you to use this.value
in callbacks.
awesome, pr is coming