ReactiveSet<E>.wrap constructor

ReactiveSet<E>.wrap(
  1. Set<E> set
)

Makes any set reactive by wrapping it.

If the argument is already a subclass of ReactiveSet, returns the argument.

Example

import 'package:kind/kind';

void main() {
  final nonReactiveSet = <String>{'a', 'b', 'c'};
  final reactiveSet = ReactiveSet<String>.wrap(nonReactiveSet);

  // ReactiveSystem can observe the read event.
  reactiveSet.first;

  // ReactiveSystem can observe the write event.
  reactiveSet.add('added value');
}

Implementation

factory ReactiveSet.wrap(Set<E> set) {
  if (set is ReactiveSet<E>) {
    return set;
  }
  return _ReactiveSet(set);
}