Open
Description
At the moment, when you create a subscribe query, the query will automatically pass all ops back to the client, regardless of whether it wants to be subscribed or not. This can be quite confusing:
- a
Doc
that matches a subscribe query will receive'op'
events, even thoughdoc.subscribed === false
- calling
doc.unsubscribe()
will not actually stop the doc receiving'op'
events
It's possible to make this behaviour a bit more consistent in a few ways:
- check at the server if the client doc is subscribed, and only send ops back in that case
- make
connection.get()
return new instances of docs rather than cached instances (which I've personally always expected) — this would allow individualDoc
instances to be unsubscribed, whilequery.results
stay subscribed
At the very least it might be nice to error in doc.unsubscribe()
if the doc matches a query (and therefore cannot be unsubscribed). It may also be nice to change doc.subscribed
into a method/getter which checks if it's part of a query, to reflect its "true" state
All of the above changes would technically be breaking.
One nice, non-breaking thing we could potentially do is to just logger.warn()
if unsubscribing a doc that matches a query.