Open BawdyInkSlinger opened 3 years ago
I have the same problem as well
document.arrive(".class", {fireOnAttributesModification:true,existing:true,onceOnly:true}, function() {
document.unbindArrive(".class")
console.log('only called once')
});
Unfortunately it is called for each element of class "class"
I found this because I wanted to make sure that it was fired once for each element matching the selector.
The suggestion would be a non-obvious breaking change if changing the functionality of onceOnly
, so if implemented it should be a new parameter, or at least make it an obvious breaking change by renaming onceOnly
to onceOnlyPerElement
and adding a new parameter for the new functionality.
Any news with this?
I don't think the { onceOnly: boolean } option works the way i want. I think it applies to each element it finds in the selector. I don't want this, I want something that I don't think the library can do: I want the observer to fire only once, regardless of how many elements I set it on.
e.g.,
This is useful because I don't want to fire it until a li is visible on the page, but I also don't want to run the body of the function more than once.
Honestly, this and a lot of other useful features could be used if the API let you pass in a jquery instead of a string.
Of course, the library is a black box to me, and I don't know if that's a feasible implementation.