Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3893bb5

Browse files
authored
Update Readme.md
1 parent 119328b commit 3893bb5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

β€Žlibs/state/selections/docs/Readme.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ProblemComponent {
104104
viewModel$: Observable<ViewModel>; // ???
105105

106106
constructor(private globalState: GlobalState, private state: RxState<Model>) {
107-
this.state.set({title: 'My list'})
107+
this.state.connect('title', this.globalState.title$);
108108
this.state.connect('products', this.globalState.products$);
109109
}
110110

@@ -144,11 +144,11 @@ export class ProblemComponent {
144144
selectSlice(['title', 'sortedList', 'sortDirection'])
145145
)
146146

147-
// BAD: modle viewmodel mix up πŸ‘‡
147+
// ❌ BAD: modle viewmodel mix up πŸ‘‡
148148
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 πŸ‘‡
152152
this.state.connect('sortedList', this.sortedList$);
153153
}
154154

@@ -174,12 +174,12 @@ export class ProblemComponent {
174174
})
175175
);
176176

177-
// GOOD: Derive view model from model πŸ‘‡
177+
// βœ” GOOD: Derive view model from model πŸ‘‡
178178
viewModel$ = smosh({ title: this.state.select('title')}, this.sortedSlice$);
179179

180180
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+
183183
}
184184

185185
// ...

0 commit comments

Comments
Β (0)