|
| | FlowSession (::morph::bridge::BridgeHandler< Model > &handler, std::function< void(std::exception_ptr)> onError=nullptr) |
| | Constructs a flow over handler, starting at step 0.
|
| | ~FlowSession () |
| | Stops every callback this session installed from being delivered.
|
|
| FlowSession (const FlowSession &)=delete |
|
FlowSession & | operator= (const FlowSession &)=delete |
|
| FlowSession (FlowSession &&)=delete |
|
FlowSession & | operator= (FlowSession &&)=delete |
| template<auto FieldPtr> |
| void | set (typename ::morph::bridge::detail::MemberPointerTraits< decltype(FieldPtr)>::ValueType value) |
| | Sets one field of the current step's draft and dispatches the step as soon as its ActionValidator reports the draft ready.
|
| bool | advance () |
| | Moves to the next step, if the current step has already produced a successful result (a not-ready step does not advance).
|
| bool | back () |
| | Returns to the previous step. Its draft — this session's own std::get<A>(_drafts) slot, the only draft in play — was never reset, so its entered values are intact.
|
| bool | finished () const noexcept |
| | Whether the flow has advanced past the last step.
|
| bool | ready () const noexcept |
| | Whether the current step already has a captured, successful result.
|
| std::size_t | currentIndex () const noexcept |
| | The current 0-based step position.
|
| std::string_view | currentActionType () const noexcept |
| | The registered type-id of the current step's action.
|
| std::optional< std::string > | resolved (std::string_view path) const |
| | Looks up a value captured from an earlier step's submitted draft or result.
|
template<typename Model, typename... Steps>
class morph::flows::FlowSession< Model, Steps >
Sequences an ordered list of registered actions (Steps...) as one multi-step flow sharing captured values across steps.
Each step is fired through the handler's ordinary one-shot dispatch (BridgeHandler::execute<A>() → Completion<R>, bridge.hpp) — a FlowSession contributes only sequencing (advance/back), the per-step drafts and their readiness gate, and a resolved-values map callers use to prefill a later step from an earlier one's submitted fields or result. The handler holds no draft on a flow's behalf: nothing here goes through handler-side draft machinery.
Steps... must be pairwise distinct action types: this session's drafts live in a std::tuple<Steps...> addressed by type (std::get<A>(_drafts)), and std::get<T> is ill-formed when T occurs more than once — which is what the AllDistinct<Steps...> assert below enforces.
- Template Parameters
-
| Model | Concrete model type owning the BridgeHandler this flow dispatches through. |
| Steps | Ordered, pairwise-distinct action types (the flow's steps). |
Definition at line 153 of file flows.hpp.
template<typename Model, typename... Steps>
Stops every callback this session installed from being delivered.
There is nothing to detach. A step's callbacks are .then/.onError continuations on the Completion that BridgeHandler::execute<A>() returned — already owned by the in-flight dispatch, not held in a map this session could remove itself from, and possibly running on another thread the moment this destructor starts. _callbacks gates every installed callback on a token the callback checks before touching this.
The session is destroyed on the handler's owner, where the step's continuations are delivered, so check-then-run is atomic: a callback still in flight is refused instead of touching a destroyed object.
requestStop() is called explicitly rather than left to the member's own destruction, even though _callbacks is declared last: members are destroyed only after the destructor body, so a body that grew a call pumping an event loop would otherwise deliver into a half-dead session. This is the "teardown that pumps" escape hatch docs/spec/core/callback_scope.md documents; the body here does not do that today, but stopping first keeps the destructor correct if one is added.
Definition at line 204 of file flows.hpp.
template<typename Model, typename... Steps>
template<auto FieldPtr>
| void morph::flows::FlowSession< Model, Steps >::set |
( |
typename ::morph::bridge::detail::MemberPointerTraits< decltype(FieldPtr)>::ValueType | value | ) |
|
|
inline |
Sets one field of the current step's draft and dispatches the step as soon as its ActionValidator reports the draft ready.
The draft is this session's own (std::get<A>(_drafts)), the readiness check is made here, and a ready draft is fired by this session's fireStep<A> through BridgeHandler::execute<A>(). The handler keeps no draft of its own, so there is nothing to forward to.
- No in-flight coalescing
- Every set<> that leaves the draft ready dispatches, including one made while an earlier dispatch is still in flight. Keystroke-rate calls on an already-complete draft therefore produce one request each, and their results arrive in whatever order the backend answers them — the last reply to land wins, which need not be the last call made. An earlier handler-side draft did collapse patches arriving during a flight; nothing does now, here or on the standalone-form path. A caller that wants one request per pause throttles or debounces on its own side.
- Template Parameters
-
| FieldPtr | Pointer-to-data-member of the current step's action struct. |
- Parameters
-
| value | New value for the field. |
- Exceptions
-
| std::logic_error | if FieldPtr's action is not the current step. |
Definition at line 237 of file flows.hpp.