You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When once is called multiple times with the same path, the first one that receives an update will unsubscribe the path and therefore the second one is never called.
db.get('path').once(()=>{// receives update and unsubscribes from path});db.get('path').once(()=>{// never receives update})db.get('path').set('test');
Now, this took me a while to figure out, but the issue comes down to this:
For some reason I chose to use Array.splice to remove listeners.
This was a really bad idea. Because now, if someone unsubscribes from a path while an iteration over all listeners is in progress, the iteration does behave weirdly, as splice will remove items in place. Therefore skipping the last once in the example above.
Replacing splice with a simple Array.filter should be enough to fix the issue.
what it does
When
once
is called multiple times with the same path, the first one that receives an update will unsubscribe the path and therefore the second one is never called.Issue is basically this line:
socketdb/src/client.ts
Line 274 in 8f8e601
what it should do
All
once
listener should be called when an update arrives.The text was updated successfully, but these errors were encountered: