Computed<T>.withDependencies constructor

  1. @Deprecated('Use Computed(() => ...) with automatic dependency tracking')
Computed<T>.withDependencies(
  1. T compute(),
  2. List<NeuronAtom> dependencies, {
  3. String? debugLabel,
  4. bool equals(
    1. T a,
    2. T b
    )?,
  5. T guard(
    1. T current,
    2. T next
    )?,
  6. VoidCallback? onListen,
  7. VoidCallback? onCancel,
})

Legacy constructor for backward compatibility.

Accepts explicit dependencies list. Prefer the auto-tracking constructor.

Implementation

@Deprecated('Use Computed(() => ...) with automatic dependency tracking')
factory Computed.withDependencies(
  T Function() compute,
  List<NeuronAtom> dependencies, {
  String? debugLabel,
  bool Function(T a, T b)? equals,
  T Function(T current, T next)? guard,
  VoidCallback? onListen,
  VoidCallback? onCancel,
}) {
  final computed = Computed<T>(
    compute,
    debugLabel: debugLabel,
    equals: equals,
    guard: guard,
    onListen: onListen,
    onCancel: onCancel,
  );
  // Force these as dependencies even if not accessed in first compute
  computed._dependencies = dependencies.toSet();
  if (computed.hasListeners) {
    computed._subscribeAll();
  }
  return computed;
}