diff options
author | Dennis Neufeld <dennis.neufeld@students.bfh.ch> | 2020-10-23 19:50:33 +0200 |
---|---|---|
committer | Dennis Neufeld <dennis.neufeld@students.bfh.ch> | 2020-10-23 19:50:33 +0200 |
commit | 9da4ba3b74d5725160831cce8ec94e5e2f47daf7 (patch) | |
tree | 1fe84686d9c16857cc1db2267a7bb11ff76c9ce0 /anastasis.rst | |
parent | 785bc590ce6be5e88624ba5bfc195ec040270d93 (diff) | |
download | docs-9da4ba3b74d5725160831cce8ec94e5e2f47daf7.tar.gz docs-9da4ba3b74d5725160831cce8ec94e5e2f47daf7.tar.bz2 docs-9da4ba3b74d5725160831cce8ec94e5e2f47daf7.zip |
anastasis reducer
Diffstat (limited to 'anastasis.rst')
-rw-r--r-- | anastasis.rst | 69 |
1 files changed, 69 insertions, 0 deletions
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 |