MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / UnsubscribeThen

Method UnsubscribeThen

sdks/csharp/src/Event.cs:258–282  ·  view source on GitHub ↗

Unsubscribe from the query controlled by this subscription handle, and call onEnded when its rows are removed from the client cache.

(Action<SubscriptionEventContext>? onEnded)

Source from the content-addressed store, hash-verified

256 /// and call onEnded when its rows are removed from the client cache.
257 /// </summary>
258 public void UnsubscribeThen(Action<SubscriptionEventContext>? onEnded)
259 {
260 if (state is not SubscriptionState.Active)
261 {
262 throw new Exception("Cannot unsubscribe from inactive subscription.");
263 }
264 if (this.onEnded != null)
265 {
266 throw new Exception("Unsubscribe already called.");
267 }
268 if (onEnded == null)
269 {
270 // We need to put something in there to use this as a boolean.
271 onEnded = (ctx) => { };
272 }
273 this.onEnded = onEnded;
274 if (queryId == null)
275 {
276 Log.Warn("Unsubscribing from a query that was never submitted to the server does nothing.");
277 }
278 else
279 {
280 conn.Unsubscribe(queryId);
281 }
282 }
283 }
284}

Callers 1

StartMainUnsubscribeFunction · 0.45

Calls 2

WarnMethod · 0.45
UnsubscribeMethod · 0.45

Tested by

no test coverage detected