This moves the source subscription to the result writable in queryStore and subscriptionStore. We must subscribe when the StartStopNotifier is called, so to start the subscription whenever there isn't an active one to the Client.
If we don't start the subscription on demand, then unsubscribing (with all observers) from the stores will let them “die”. They won’t have an active subscription and won’t be able to start a new one.
The writable in Svelte already checks when to call StartStopNotifier via semaphore logic, so no extra code is needed.
The only risk with this fix is whether people relied on queryStore starting a subscription implicitly. This really shouldn't have been done before as it's pointless to instantiate a store without reading from it, so I don't consider it a breaking change — unless there's a specific reproduction that is proven to break from this change.
Set of changes
Move Client subscription into writable instantiation
Resolves #3329
Summary
This moves the source subscription to the result
writable
inqueryStore
andsubscriptionStore
. We must subscribe when theStartStopNotifier
is called, so to start the subscription whenever there isn't an active one to theClient
.If we don't start the subscription on demand, then unsubscribing (with all observers) from the stores will let them “die”. They won’t have an active subscription and won’t be able to start a new one.
The
writable
in Svelte already checks when to callStartStopNotifier
via semaphore logic, so no extra code is needed.The only risk with this fix is whether people relied on
queryStore
starting a subscription implicitly. This really shouldn't have been done before as it's pointless to instantiate a store without reading from it, so I don't consider it a breaking change — unless there's a specific reproduction that is proven to break from this change.Set of changes
Client
subscription intowritable
instantiation