reduce method

  1. @override
IdentifiableMap<Object, StageSend> reduce(
  1. IdentifiableMap<Object, StageSend> entities,
  2. StageMsg msg
)

Fold a message into the registry's keyed collection and return the NEXT collection. PURE — replay depends on it; no side effects, no clocks. A message may touch MANY entries (a batch load) or none. The identifiable map extensions keep it terse: entities.upsert(x) · entities.upsertAll(xs) · entities.removeById(id) · entities.updateById(id, (cur) => …).

Implementation

@override
IdentifiableMap<Object, StageSend> reduce(
  IdentifiableMap<Object, StageSend> entities,
  StageMsg msg,
) => switch (msg) {
      SendDisplaced(:final send) => entities.upsert(send),
      SendGone(:final tag) => entities.removeById(tag),
      FlightLanded(flight: Flight(kind: .dismissing || .effect)) =>
        entities.isEmpty ? entities : const {},
      FlightLanded() ||
      SendArrived() ||
      SendsRecalled() ||
      StageTaken() ||
      ModeSet() ||
      OriginPointed() ||
      OriginMeasured() ||
      WidgetShown() ||
      AspectRatioSet() ||
      BackgroundSet() ||
      GestureBuilderSet() ||
      OnEndSet() ||
      FlightTook() ||
      InteractionBegan() ||
      InteractionEnded() ||
      OriginGestureSet() ||
      HybridDrivingSet() =>
        entities,
    };