smetankajakub / todo-list-v2

0 stars 0 forks source link

State management #9

Open majirosstefan opened 3 years ago

majirosstefan commented 3 years ago

Lib:

https://ngrx.io/

Store example

{
 todoLists: [ { name: "", items: []}, { name: "", items: [{name: "item1", value: "item1value" }]} ]
 auth: { isAuthorized: true},
 newItem: {}
 }
                                                               rootObject

todoLists                                    auth                                                     newItem

name, items                              isAuthorized                                            {}
majirosstefan commented 3 years ago

for demonstration, add checkbox next to the global searchbar . If checked, search only local store, if not, fire request to mockAPI / backend.

majirosstefan commented 3 years ago

example for fetching BACKEND:

dispatch action: fetchingStarted from component then, get data = dispatch setData(data) if error => dispatch setError(error)