reduce method

  1. @override
StageStance reduce(
  1. StageStance state,
  2. StageMsg msg
)

Fold a message into the value and return the NEXT value. PURE.

Implementation

@override
StageStance reduce(StageStance state, StageMsg msg) => switch (msg) {
      FlightTook(:final flight) when flight.isMode =>
        state._with(modeFlight: flight),
      FlightTook(:final flight) => state._with(flight: flight),
      FlightLanded(:final flight) => switch (flight.kind) {
          .changingMode => state._with(modeFlight: null),
          .opening => state._with(flight: null, open: true),
          // The session ends; an Origin's gesture outlives it.
          .dismissing || .effect => StageStance(
              originGesture: state.originGesture,
              hybridDriving: state.hybridDriving,
            ),
        },
      InteractionBegan() => state._with(interacting: true),
      InteractionEnded() => state._with(interacting: false),
      OriginGestureSet(:final gesture) => state._with(originGesture: gesture),
      HybridDrivingSet(:final driving) => state._with(hybridDriving: driving),
      StageTaken() ||
      ModeSet() ||
      OriginPointed() ||
      OriginMeasured() ||
      WidgetShown() ||
      AspectRatioSet() ||
      BackgroundSet() ||
      GestureBuilderSet() ||
      OnEndSet() ||
      SendDisplaced() ||
      SendArrived() ||
      SendsRecalled() ||
      SendGone() =>
        state,
    };