map<T, V> static method

Event<T> map<T, V>(
  1. Event<V> evt,
  2. T? mapFunction(
    1. V?
    )
)

This is a convenience factory to create an event which is transformed by some function that, usually, needs the store state. You must provide the event and a map-function. The map-function must be able to deal with the spent state (null or false, accordingly).

For example, if state.indexEvt = Event<int>(5) and you must get a user from it:

var mapFunction = (int index) => index == null ? null : state.users[index];
Event<User> userEvt = Event.map(state.indexEvt, mapFunction);

Implementation

static Event<T> map<T, V>(Event<V> evt, T? Function(V?) mapFunction) =>
    MappedEvent<V, T>(evt, mapFunction);