dispose method

void dispose()

Releases resources used by this computed instance.

This method cancels the internal subscription to source changes and closes the stream controller. It should be called when the computed instance is no longer needed to avoid memory leaks.

After calling dispose, the computed value will no longer update in response to changes in its sources, and any attempt to listen to the stream will result in an error.

Example:

final counter = Reactive(0);
final doubled = Computed([counter], (sources) => sources[0].value * 2);

// Use the computed value...

// When done with the computed value:
doubled.dispose();

Implementation

void dispose() {
  _subscription?.cancel();
  _subscription = null;
  _controller.close();
}