Open yohash opened 2 months ago
To consider here are the merits between:
Action
in Middleware
vs. Component
Component
rendering (updating), we won't be returning elements to mount. Elements
are mounted in response to state, so they can persist as extensions of the Component.Props
.Is there truly value to hooking into an Action
from a Component
? Maybe for one-off events, but there must be true value to triggering these 1-off events in Components
instead of Middleware
. Without the benefit of mounting an Element
, is there any value add?
Each Action would have a
delegate Dispatched(IAction action)
that is static to eachIAction
type. AnyComponent
can attach to it by subscribing to the static delegate,public static Dispatched OnDispatch;
.This will allow a
Component
to latch on to actions like "events".Motivation: It is difficult to "trigger" game effects using state. The pattern tends towards:
IAction
mutates some FSM in state to a "has been triggered" typeComponent
will initiate its triggered effect, and then dispatches a "trigger initiated" typeIAction
Alternately, we can of course compare
if (oldProps.Value != props.Value)
, but this still leaves us needing to "reset" the "trigger var".This sort of "action as event" might be nice to try out.