|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Talks to the server's preferences model (morph.preferences) for one application, through the interpreter's Dispatcher. More...
#include <preference_sync.hpp>
Public Member Functions | |
| PreferenceSync (Dispatcher &dispatcher, std::string application, std::function< void(std::string const &)> onError={}) | |
A sync for application. | |
| void | load (Screen &screen, async::CallbackScope const &scope, std::function< void(std::expected< PreferencesLoaded, std::string >)> done={}) |
Loads screen's stored choices, in one call for all its points, and sets each that fits. | |
| void | changed (std::string const &screen, std::string const &point, Value const &value) |
| Stores the user's choice at a point. | |
| void | reset (std::string const &screen, std::string const &point) |
| Forgets the stored choice at a point, or at every point of a screen this sync has loaded. | |
Talks to the server's preferences model (morph.preferences) for one application, through the interpreter's Dispatcher.
An application's InterpreterHost holds one, calls load after it mounts a screen, and forwards preferenceChanged to changed and resetPrefs to reset. No call names a person: the server keys every entry by the verified session's principal. All calls are made on the runtime's owner, where their replies arrive.
Definition at line 44 of file preference_sync.hpp.
|
inline |
A sync for application.
| dispatcher | Where model calls go. Borrowed: it must outlive the sync. |
| application | The application's id, the app of every key. |
| onError | Told the reason when a write fails; empty to ignore failures. |
Definition at line 50 of file preference_sync.hpp.
|
inline |
Loads screen's stored choices, in one call for all its points, and sets each that fits.
A point with no stored entry keeps the document's default. A stored entry that does not parse as the point's type, or that the point refuses (Screen::setPreference), is ignored, so a new document version never breaks on an old choice. A screen with no points makes no call and reports at once.
| screen | The mounted screen. Borrowed until the reply is delivered or scope stops. |
| scope | Gates the delivery: stop or destroy it with the screen, and nothing touches the screen after. |
| done | Called once with what was applied and ignored, or the reason the call failed; may be empty. |
Definition at line 62 of file preference_sync.hpp.
|
inline |
Stores the user's choice at a point.
| screen | The screen's id. |
| point | The point. |
| value | The choice. |
Definition at line 99 of file preference_sync.hpp.
|
inline |
Forgets the stored choice at a point, or at every point of a screen this sync has loaded.
| screen | The screen's id. |
| point | The point, or all. |
Definition at line 111 of file preference_sync.hpp.