uzairfarooq/arrive

unbindArrive by selector doesn't work

Kesantielu opened this issue · 5 comments

Example:
document.arrive('.some_class', {existing: true}, function () { if (some_trigger) document.unbindArrive('.some_class') }

After unbinding event still fires.

Is it possible that the if (some_trigger) statement never becomes true?

Asking because we have test cases for unbindArrive function and all those test cases are passing so either the bug occur in some very specific case or some issue with your code.

I added console.log() before unbinding to make sure with some_trigger works. A record appears in the log, but arrive event fires again...

While debugging I found that length of _eventsBucket is 0 when unbindArrive calling.

Hmm...thanks. Will look into it over the coming weekend. I think it might be related to synchronous callback. Can you try unbind within a timer, like this setTimeout(function (){document.unbindArrive('.some_class')}, 1)

@Kesantielu It's very likely, that you might want to move your flag variable some_trigger in the parent scope—just to the parent scope of your current logic.