Computed<T>.withDependencies constructor
- @Deprecated('Use Computed(() => ...) with automatic dependency tracking')
- T compute(),
- List<
NeuronAtom> dependencies, { - String? debugLabel,
- bool equals(
- T a,
- T b
- T guard(
- T current,
- T next
- VoidCallback? onListen,
- 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;
}