@@ -298,6 +298,34 @@ all the value types in the original cursors:
298298 lager::reader<std::tuple<int, std::string>> dual_ro =
299299 lager::with(num, str_ro);
300300
301+ .. _derive-a-read-write-cursor-from-a-read-only-one :
302+
303+ Derive a read-write cursor from a read-only one
304+ ---------------
305+
306+ You can use ``lager::with_setter `` to derive a read-write cursor from a
307+ read-only cursor.
308+
309+ .. code-block :: c++
310+
311+ #include <lager/setter.hpp>
312+
313+ auto store = lager::make_store<int>(
314+ 0,
315+ lager::with_manual_event_loop{},
316+ lager::with_reducer([](int s, int a) { return a; }));
317+ auto cursor = lager::with_setter(
318+ store,
319+ [&](int x) { store.dispatch(x); });
320+
321+ store.dispatch(42);
322+ std::cout << store.get() << std::endl; // 42
323+ std::cout << cursor.get() << std::endl; // 42
324+
325+ cursor.set(5);
326+ std::cout << cursor.get() << std::endl; // 5
327+ std::cout << store.get() << std::endl; // 5
328+
301329.. _using-cursors :
302330
303331Using cursors
@@ -451,15 +479,15 @@ room model and watch it for changes:
451479 });
452480 }
453481 };
454-
482+
455483.. note :: A ``lager::watch(reader, ...)`` is bound to the
456484 ``reader `` object. It is simply an alias of
457485 ``reader.watch(...) ``. This means that when the reader
458486 object goes out of scope, the watch is disposed. For
459487 example:
460488
461489 .. code-block :: c++
462-
490+
463491 void setup_watch() {
464492 auto reader = my_store[&my_model::foo];
465493
0 commit comments