useEvent<T, R> function

StableEventCallback<T, R> useEvent<T, R>(
  1. R handler(
    1. T value
    )
)

Returns a stable callback that always invokes the latest handler.

Unlike useCallback, changing handler never changes the returned callback's identity. Use a record as T when an event carries multiple values.

Implementation

StableEventCallback<T, R> useEvent<T, R>(R Function(T value) handler) {
  return use(_EventHook<T, R>(handler));
}