Skip to content

Conversation

@arildm
Copy link
Member

@arildm arildm commented Sep 6, 2018

AppState hade allt jox under en property som hette searchRedux. Jag har delat upp det i tre: query, document och ui, eftersom olika komponenter/services tenderar att använda specifikt någon av dessa.

Jag har också börjat gå från att bero helt på vilken action det är som utförs (genom att spara och läsa av latestAction) till att kolla av state och sedan uppdatera vad som behöver uppdateras.

Ett bra exempel är AppComponent:

-    this.searchRedux = this.store.select('searchRedux');
-
-    this.searchRedux.pipe(filter((d) => [CHANGELANG, INITIATE].includes(d.latestAction))).subscribe((data) => {
-      this.selectedLanguage = data.lang;
-    });
+    this.store.select('ui').subscribe(ui => {
+      this.selectedLanguage = ui.lang;
+    });

-    this.searchRedux.pipe(filter((d) => d.latestAction === OPENDOCUMENT)).subscribe((data) => {
-      console.log("|openDocument");
-      this.openDocument = true;
-    });
- 
-    this.searchRedux.pipe(filter((d) => d.latestAction === CLOSEDOCUMENT)).subscribe((data) => {
-      console.log("|closeDocument");
-      this.openDocument = false;
-    });
+    this.store.select('document').subscribe((document) => {
+      console.log(document.open ? "|openDocument" : "|closeDocument");
+      this.openDocument = document.open;
+    });

@arildm arildm changed the title Decompose redux WIP: Decompose redux Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants