From 9da4ba3b74d5725160831cce8ec94e5e2f47daf7 Mon Sep 17 00:00:00 2001 From: Dennis Neufeld Date: Fri, 23 Oct 2020 19:50:33 +0200 Subject: anastasis reducer --- anastasis.rst | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'anastasis.rst') diff --git a/anastasis.rst b/anastasis.rst index 355d0d7a..f7232c59 100644 --- a/anastasis.rst +++ b/anastasis.rst @@ -815,10 +815,79 @@ Anastasis Reducer API This section describes the Anastasis Reducer API which is used by client applications to store or load the different states the client application can have. +The reducer takes a state_ in JSON syntax and returns the new state in JSON syntax. + +For example a **state** may take the following structure: +:: + + { + "backup_state": "CONTINENT_SELECTING", + "continents": [ + "Europe", + "North_America" + ] + } + +The new state depends on the previous one and on the transition action_ with its +arguments given to the reducer. A **transition argument** also is a statement in JSON syntax: +:: + + { + "continent": "Europe" + } + +The new state returned by the reducer with the state and transition argument defined +above would look like following for the transition action_ "select_continent": +:: + + { + "backup_state": "COUNTRY_SELECTING", + "continents": [ + "Europe", + "North_America" + ], + "selected_continent": "Europe", + "countries": [ + { + "code": "ch", + "name": "Switzerland", + "continent": "Europe", + "name_i18n": { + "de_DE": "Schweiz", + "de_CH": "Schwiiz", + "fr": "Suisse", + "en": "Swiss" + }, + "currency": "CHF" + }, + { + "code": "de", + "name": "Germany", + "continent": "Europe", + "continent_i18n": { + "de": "Europa" + }, + "name_i18n": { + "de_DE": "Deutschland", + "de_CH": "Deutschland", + "fr": "Allemagne", + "en": "Germany" + }, + "currency": "EUR" + } + ] + } + +**State**: + - In SELECTING-States the user has to choose one value out of a predefined set of values (for example a continent out of a set of continents). + - In COLLECTING-States the user has to give certain values. + - In EDITING-States the user is free to choose which values he wants to give. Backup Reducer ^^^^^^^^^^^^^^ +.. _state: +.. _action: .. figure:: anastasis_reducer_backup.png :name: fig-anastasis_reducer_backup :alt: fig-anastasis_reducer_backup -- cgit v1.2.3