castFrom<S, T> static method

StreamList<T> castFrom<S, T>(
  1. List<S> source, {
  2. OnUpdate<List<T>>? onUpdate,
  3. OnEvent<CollectionEvent<int, T>>? onEvent,
  4. OnChange<CollectionChangeEvent<int, T>>? onChange,
})
override

Adapts source to be a StreamList<T>.

Any time the list would produce an element that is not a T, the element access will throw.

Any time a T value is attempted stored into the adapted list, the store will throw unless the value is also an instance of S.

If all accessed elements of source are actually instances of T, and if all elements stored into the returned list are actually instance of S, then the returned list can be used as a StreamList<T>.

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

static StreamList<T> castFrom<S, T>(
  List<S> source, {
  OnUpdate<List<T>>? onUpdate,
  OnEvent<CollectionEvent<int, T>>? onEvent,
  OnChange<CollectionChangeEvent<int, T>>? onChange,
}) {
  return StreamList(
    value: List.castFrom<S, T>(source),
    onUpdate: onUpdate,
    onEvent: onEvent,
    onChange: onChange,
  );
}