map<Inner, Msg> static method

Sub<Msg> map<Inner, Msg>(
  1. String idPrefix,
  2. Sub<Inner> sub,
  3. Msg f(
    1. Inner
    )
)

Map a subscription from a message to a new subscription with another message.

Implementation

static Sub<Msg> map<Inner, Msg>(
        String idPrefix, Sub<Inner> sub, Msg Function(Inner) f) =>
    Sub(sub._subs.map((inner) {
      final (subId, subscribe) = inner;
      return (
        [idPrefix, ...subId],
        (dispatch) => subscribe((innerDispatch) => dispatch(f(innerDispatch)))
      );
    }).toList());