onDispose method

  1. @override
EffectCleanup onDispose(
  1. void cleanup()
)
override

Add a cleanup function to be called when the signal is disposed

final counter = signal(0);
final effectCount = signal(0);

final cleanup = counter.onDispose(() {
 print('Counter has been disposed');
});

// Remove the cleanup function
cleanup();

Implementation

@override
EffectCleanup onDispose(void Function() cleanup) {
  return instance.onDispose(cleanup);
}