create<V, I extends Iterable<V>> static method

CollectiveValue<V> create<V, I extends Iterable<V>>({
  1. V? value,
  2. Cell? bind,
  3. ContainerType container = ContainerType.growableFalse,
  4. CollectiveReceptor<dynamic, Signal, Signal> receptor = CollectiveReceptor.unchanged,
  5. TestCollective<dynamic, Collective> test = TestCollective.passed,
  6. MapObject? mapObject,
  7. Synapses<Signal, Cell> synapses = Synapses.enabled,
  8. bool setter(
    1. CollectiveValue<V> value,
    2. I container,
    3. V? v
    )?,
  9. V? getter(
    1. CollectiveValue<V> value,
    2. I container
    )?,
})
override

Factory constructor for full configuration.

Parameters:

  • value: Initial value
  • bind: Cell to bind to
  • container: Container type (defaults to ContainerType.value)
  • receptor: Signal handling configuration
  • test: Validation rules
  • map: Value transformations
  • synapses: Connection configuration
  • setter: Custom value setter function
  • getter: Custom value getter function

Implementation

static CollectiveValue<V> create<V, I extends Iterable<V>>({
  V? value,
  Cell? bind,
  ContainerType container = ContainerType.growableFalse,
  CollectiveReceptor receptor = CollectiveReceptor.unchanged,
  TestCollective test = TestCollective.passed,
  MapObject? mapObject,
  Synapses synapses = Synapses.enabled,
  bool Function(CollectiveValue<V> value, I container, V? v)? setter,
  V? Function(CollectiveValue<V> value, I container)? getter,
}) {
  Record record;
  if (test == TestCollective.passed && mapObject == null && synapses == Synapses.enabled) {
    if (bind != null || container != ContainerType.growableFalse || receptor != CollectiveReceptor.unchanged) {
      record = (
        bind: bind,
        container: container != ContainerType.growableFalse ? container : ContainerType.create<V,I>(),
        receptor: receptor
      );
    } else {
      record = ();
    }
  } else {
      record = (bind: bind,
      container: container,
      receptor: receptor == CollectiveReceptor.unchanged ? CollectiveReceptor<V,CollectivePost,CollectivePost>() : receptor,
      test: test,
      mapObject: mapObject,
      synapses: synapses, setter: setter, getter: getter
    );
  }
  return _CollectiveValue<V>.fromProperties(CollectiveValueProperties<V>.fromRecord(record), value: value);
}