@@ -104,7 +104,7 @@ export class ProblemComponent {
104
104
viewModel$: Observable <ViewModel >; // ???
105
105
106
106
constructor (private globalState : GlobalState , private state : RxState <Model >) {
107
- this .state .set ({ title: ' My list ' })
107
+ this .state .connect ( ' title' , this . globalState . title$ );
108
108
this .state .connect (' products' , this .globalState .products$ );
109
109
}
110
110
@@ -144,11 +144,11 @@ export class ProblemComponent {
144
144
selectSlice ([' title' , ' sortedList' , ' sortDirection' ])
145
145
)
146
146
147
- // BAD: modle viewmodel mix up π
147
+ // β BAD: modle viewmodel mix up π
148
148
constructor (private globalState : GlobalState , private state : RxState <Model & Pick <ViewModel , ' sortedList' >>) {
149
- this . state . set ({title: ' My list ' })
150
- this . state . connect ( ' products ' , this . globalState . products$ );
151
- // BAD: store derived state π
149
+ // ...
150
+
151
+ // β BAD: store derived state π
152
152
this .state .connect (' sortedList' , this .sortedList$ );
153
153
}
154
154
@@ -174,12 +174,12 @@ export class ProblemComponent {
174
174
})
175
175
);
176
176
177
- // GOOD: Derive view model from model π
177
+ // β GOOD: Derive view model from model π
178
178
viewModel$ = smosh ({ title: this .state .select (' title' )}, this .sortedSlice$ );
179
179
180
180
constructor (private globalState : GlobalState , private state : RxState <Model >) {
181
- this . state . set ({title: ' My list ' });
182
- this . state . connect ( ' products ' , this . globalState . products$ );
181
+ // ...
182
+
183
183
}
184
184
185
185
// ...
0 commit comments