Skip to content

Commit 18c650d

Browse files
committed
Update rest api diagram
1 parent 20d38eb commit 18c650d

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

examples/rest-api-example/README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,38 @@ the new state automatically by subscribing to a getter.
2020
**Unidirectional data flow**
2121

2222
```
23-
+--------->[restApiCache store]
24-
| | |
25-
[server] | |
26-
| | | *getter*
27-
| | |
28-
| / \
29-
| / \
30-
| **save** / \
31-
+------[component A] [component B]
23+
┌────────────────────┐
24+
│ Nuclear AppState │
25+
┌───────────┴────────────────────┴───────────┐
26+
│ { │
27+
│ restApiCache: { │
28+
│ experiments: { │
29+
│ 1: { id: 1, project_id: 45, ... }, │
30+
┌─────────────────────▶│ 2: { id: 2, project_id: 123, ... }, │
31+
┌─────────┴─────────┐ │ } │
32+
│ Response updates │ │ }, │
33+
│ global app state │ │ } │
34+
└─────────┬─────────┘ └────────────────────────────────────────────┘
35+
│ │
36+
┌─────────────┐ │
37+
│ │ │
38+
│ Rest API │ │
39+
│ (server) │ ▼
40+
│ │ ┌───────────────────────┐
41+
└─────────────┘ │ Updated App State │
42+
▲ │ Recomputes Getter │
43+
│ └───────────────────────┘
44+
┌───────────┴────────────┐ │
45+
│ Module action triggers │ │
46+
│ API request │ ┌────────────┴────────────┐
47+
└───────────┬────────────┘ │ │
48+
│ │ │
49+
│ ▼ ▼
50+
┌───────────────────────────────┐ ┌───────────────────┐ ┌──────────────────┐
51+
│ Experiment.actions.fetchAll({ │ │ │ │ │
52+
│ project_id: 123 │ │ Component A │ │ Component B │
53+
│ }); │ │ │ │ │
54+
└───────────────────────────────┘ └───────────────────┘ └──────────────────┘
3255
```
3356

3457
**component A** is saving some entity to the server, the response then dispatches an action that updates the `restApiCache` store causing both **component A**

0 commit comments

Comments
 (0)