Closed tabazevedo closed 9 years ago
Interesting! I have no fundamental problem with it, just would be interested to know what the use-case is. :)
We have a bunch of dynamically generated forms and we need an onChange listener to be created for them so we can handle submission isomorphically.
The issue is they can be created multiple times if the user types in the the same or similar search query (its based on search results) but we don't want to create a new listener each time.
Hmm, should we just expose the listeners list on each cursor...? Is there any harm in doing that...? It would obvs be read only, cause of the way it's stored, but it sounds mildly useful.
You mean like.. a cursor.listeners()
method? otherwise you still need to do the finding by path (as they are only stored on the root) which would mean exposing path and root.
Yep, that's what I mean. cursor.listeners!
-> [function, function, function]
.
@tabazevedo make sure you don't return the actual array though, we don't want people to push stuff into it. It should be fine to slice()
clone it, it won't ever be massive...
Added
Sorry to be a PITA, but now we don't need has-listener
any more :)
:sob: goodbye cruel world
Quick method to check if a cursor already has a listener at its current path.
Useful for dynamically generated cursor paths.