User-intent view state — what is selected, typed, open — changed only by messages.
More...
|
template<typename Init, typename Update>
requires std::invocable<Init&, Runtime&> && std::same_as<std::invoke_result_t<Init&, Runtime&>, ViewState> &&
std::move_constructible<Update> && ExhaustiveUpdate<Update, ViewState, Msg> |
| | Store (Runtime &runtime, Init init, Update update) |
| | ~Store () |
| | Destroys the state, and tells an update still running that the Store is gone.
|
|
| Store (Store const &)=delete |
|
Store & | operator= (Store const &)=delete |
|
| Store (Store &&)=delete |
|
Store & | operator= (Store &&)=delete |
| void | send (Msg msg) |
| | Applies msg in one batch. Refused off the owner, and inside an update.
|
| ViewState const & | state () const noexcept |
| | The state, for reading. A field's get() tracks exactly that field.
|
| std::function< void()> | action (Msg msg) |
| | A callable that sends msg each time it is called — what a button binds to.
|
template<typename ViewState, typename Msg>
class morph::reactive::Store< ViewState, Msg >
User-intent view state — what is selected, typed, open — changed only by messages.
ViewState is a struct of Signal<T> fields, built in place by init (signals cannot move). Every send() runs the update in one batch, untracked, so N field writes are one flush. The view reads state(); only the update writes.
send() off the Runtime's owner is reported (detail::site::kOffOwner) and dropped, as is a send() from inside this Store's own update (detail::site::kSendInUpdate): an update is a pure state transition, and a message it sent would run against a half-applied state.
An update may destroy its own Store (a controller that closes its view): the update's callable stays alive until it returns, and send() touches nothing of the Store afterwards. The update itself must not use the state or the Store once it has destroyed them.
- Template Parameters
-
| ViewState | A struct of Signal<T> fields. |
| Msg | A std::variant of message types. |
Definition at line 93 of file store.hpp.