destroy method

Future<void> destroy()

Unsubscribe from this collection and close the event streams Also closes the event stream of each model within this collection.

Implementation

Future<void> destroy() async {
  await client.send("unsubscribe", rid, null);

  await addEventsController.close();
  await removeEventsController.close();

  await addListener.cancel();
  await removeListener.cancel();

  for (var model in models) {
    await model.destroy();
  }

  models.clear();
}