onResult method

  1. @useResult
VoidCallback onResult(
  1. void callback(
    1. K key,
    2. Result<T> result
    )
)

Registers a listener (addListener) that will be invoked with the key and result of the last modified ResultNotifier, whenever one is modified.

Use the returned VoidCallback function to unsubscribe the callback.

Implementation

@useResult
VoidCallback onResult(void Function(K key, Result<T> result) callback) {
  void listener() {
    final modification = _currentModification;
    if (modification != null) {
      callback(modification.key, modification.result);
    }
  }

  addListener(listener);
  return () => removeListener(listener);
}