Reputation: 1397
if I have an ngrx
store that consists of preferences with a sample looking like:
preferences: [{
name: 'pref1',
type: 'boolean',
value: true
}, {
name: 'pref2',
type: 'boolean',
value: true
},
...
]
how would I grab just the first stored preference as an observable chaining off this._store.select('preferences')
?
I can't find the correct syntax, although I know rxjs
has a .first()
method available. I haven't been able to find a good example of what I'm looking for to make it work.
Upvotes: 1
Views: 992
Reputation: 1397
The answer @Sasxa gave was almost exactly right. This is the solution I used to get it working:
this._store.select('preferences')
.map(preferences => preferences.filter((value, index) => index === 0))
Upvotes: 1
Reputation: 41294
This should do it:
this._store.select('preferences')
.filter((value, index) => index === 0)
Upvotes: 1