+ QtConcurrent::run([model]() { // capture model by value
+ save(model);
+ });
+#+END_SRC
+ - Performance of copying? Structural sharing, immer containers
+- Undo/redo for free
+ - History is a list of models
+ - Undo/redo = changing the current index
+ - Normal actions = push a new model onto the list
+* How to do IO?
+** Reducers revisited
+- src_c++{auto update(Model, Action) -> Model;}
+- But also src_c++{auto update(Model, Action) -> std::pair<Model, Effect>;}
+- What is an effect? A (maybe non-pure) function that takes a *context* as an argument.
+- A *store* contains the model and the context. It also has an event loop. Reducers will be run in the event loop.
+- The store can be constructed with *dependencies*, which can be accessed through the context.
+- The context can also be used to dispatch actions.
+#+INCLUDE: "src/effects-example/main.cpp" src c++
+* How can lager help you integrate value-oriented design with a Qt application?
+** Missing part: view
+- In the example, src_c++{show()} is the view.
+- We want to show the state as a src_c++{QWidget} or src_c++{QQuickItem}.
+- Signal/slot connections to update display values.
+- Cursors
* Appendix
** Calculating libQuotient coverage adjusted
libQuotient includes the generated csapi folder into coverage, while libkazv does not. Here is the code that calculates the coverage of libQuotient excluding the csapi folder.
#+NAME: libquotient-coverage
#+BEGIN_SRC perl
my $csapiCoverage = 0.169;
my $csapiUncovered = 1_668;
my $totalLines = 11_229;
my $totalUncovered = 6_561;
my $csapiLines = $csapiUncovered / (1-$csapiCoverage);
my $remainingLines = $totalLines - $csapiLines;
my $remainingUncovered = $totalUncovered - $csapiUncovered;
my $remainingCoverage = 1 - $remainingUncovered / $remainingLines;