Open mmalecki opened 10 years ago
hmm, do you mean that listeners have no way to know what the value was?
Yeah. For example, if I createSet('resource', 'Registration')
and remove documents belonging to it, the doc's remove
event will be emitted without resource
property in state (doc.get('resource') === null
).
Hmm, so you'd rather emit the remove event before the thing is actually removed? ... this creates a potential race condition... I always try and emit the event after the state is stable again, because anything can happen in the event listener, i.e. the item can join another group. what if, instead, the remove event provided the set that it was in,
set.on('remove', function (item, value, key) {
//item was removed from the key=value set
})
I think you could do the same stuff, but it wouldn't expose you to difficult bugs.
Yeah, that's why this isn't a pull request - I'm not really sure how to fix that without creating the race condition you mentioned.
I do use the set.on('remove')
walk-around.
Since
doc.set(key, null)
is called here,doc.on('remove')
listeners get a documents without the filter property.