StreamList<E> constructor

StreamList<E>({
  1. List<E>? value,
  2. OnUpdate<List<E>>? onUpdate,
  3. OnEvent<CollectionEvent<int, E>>? onEvent,
  4. OnChange<CollectionChangeEvent<int, E>>? onChange,
})

StreamList wraps a List and adds functionality to each relevant method to notify any subscribed listeners of changes made to the list.

value can be provided to return a StreamList that references value, if null an empty list will be created instead. Note: When modifying the list by referencing value, the listeners will not be notified of the changes made. StreamList's methods must be called directly in order to notify the listeners of the changes made.

If length is not null, a fixed-length list will be created. length will be ignored if value is provided.

onUpdate is a synchronous event called each time the collection is modified and receives the entire collection as a parameter.

onEvent is a synchronous event called each time the collection is modified, and receives a list of all of the affected elements.

onChange is a synchronous event called individually for every element added, removed, or updated in the collection.

Implementation

StreamList({
  List<E>? value,
  OnUpdate<List<E>>? onUpdate,
  OnEvent<CollectionEvent<int, E>>? onEvent,
  OnChange<CollectionChangeEvent<int, E>>? onChange,
}) : super(
        value ?? <E>[],
        onUpdate: onUpdate,
        onEvent: onEvent,
        onChange: onChange,
      );