|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
A form over action A: a FormSession built from schemaJson<A>(), submitting through a BridgeHandler, with typed set<>, value() and lastResult(). More...
#include <typed_form.hpp>
Public Types | |
| using | Result = model::ActionTraits<A>::Result |
| The action's registered result type. | |
| template<auto Member> | |
| using | MemberValue = bridge::detail::MemberPointerTraits<decltype(Member)>::ValueType |
The type of the member Member points to. | |
Public Member Functions | |
| Form (reactive::Runtime &runtime, bridge::BridgeHandler< M, S > &handler, ChoiceFetcher choices, FormSessionOptions options={}) | |
| Form (Form const &)=delete | |
| Form & | operator= (Form const &)=delete |
| Form (Form &&)=delete | |
| Form & | operator= (Form &&)=delete |
| FormSession & | session () noexcept |
| The session: fields, readiness, body, submission. | |
| template<auto Member> | |
| void | set (MemberValue< Member > value) |
| Sets one member, encoded with its field's encoder; a programmatic change, so nothing is submitted. | |
| std::optional< A > | value () const |
| The body decoded into A. Tracked. | |
| bool | ready () const |
| Whether the form can submit: the session is ready, which includes A's own validate(). Tracked. | |
| std::optional< Result > const & | lastResult () const |
| The last successful result: the session's last reply, decoded. Tracked. | |
| bool | pending () const |
| Whether a submission is in flight. Tracked. | |
| std::exception_ptr | error () const |
| The last failure. Tracked. | |
A form over action A: a FormSession built from schemaJson<A>(), submitting through a BridgeHandler, with typed set<>, value() and lastResult().
Non-copyable and non-movable: its session and in-flight callbacks point into it.
| A | The action type (registered with BRIDGE_REGISTER_ACTION). |
| M | The model type the handler talks to. |
| S | The handler's sharing policy. |
Definition at line 52 of file typed_form.hpp.
| using morph::forms::Form< A, M, S >::Result = model::ActionTraits<A>::Result |
The action's registered result type.
Definition at line 55 of file typed_form.hpp.
| using morph::forms::Form< A, M, S >::MemberValue = bridge::detail::MemberPointerTraits<decltype(Member)>::ValueType |
The type of the member Member points to.
| Member | A pointer to a data member of A. |
Definition at line 60 of file typed_form.hpp.
|
inline |
| runtime | The runtime; its owner must be handler's callback executor. Borrowed. |
| handler | Executes the action. Borrowed: it must outlive the form. |
| choices | Fetches Choice options; may be empty when A has no Choice member. |
| options | Locale, translations, display zone; an accepts gate is kept and joined with ActionValidator<A>. |
| std::logic_error | from FormModel::forAction<A>() when schemaJson<A>() does not read as a form model. |
Definition at line 69 of file typed_form.hpp.
|
inlinenodiscardnoexcept |
The session: fields, readiness, body, submission.
Definition at line 101 of file typed_form.hpp.
|
inline |
Sets one member, encoded with its field's encoder; a programmatic change, so nothing is submitted.
| Member | A pointer to a data member of A, e.g. &Deposit::amount. |
| value | The member's value. |
Definition at line 108 of file typed_form.hpp.
|
inlinenodiscard |
The body decoded into A. Tracked.
Definition at line 116 of file typed_form.hpp.
|
inlinenodiscard |
Whether the form can submit: the session is ready, which includes A's own validate(). Tracked.
Definition at line 121 of file typed_form.hpp.
|
inlinenodiscard |
The last successful result: the session's last reply, decoded. Tracked.
Definition at line 125 of file typed_form.hpp.
|
inlinenodiscard |
Whether a submission is in flight. Tracked.
Definition at line 129 of file typed_form.hpp.
|
inlinenodiscard |
The last failure. Tracked.
Definition at line 133 of file typed_form.hpp.