subscribe method

  1. @override
Future<ShapeSubscription> subscribe(
  1. List<Shape> shapeDefinitions, [
  2. String? key
])
override

Subscribe to a set of shapes, so that server data can get onto the client.

A set of shapes can be "named" using a key. Any subsequent calls to subscribe using this key will exchange the subscription: a new one will be subscribed, and then the old one will be unsubscribed.

If the key is not provided, it will instead be generated. Un-keyed subscriptions are deduplicated: multiple subscribe calls with exactly same shapes will result in only one subscription, and will even return the same key.

Implementation

@override
Future<ShapeSubscription> subscribe(
  List<Shape> shapeDefinitions, [
  String? key,
]) async {
  // Await for client to be ready before doing anything else
  await initializing?.waitOn();

  return _doSubscribe(shapeDefinitions, key);
}