如果我有一个ngrx
商店,其中包含以下示例的偏好设置:
preferences: [{
name: 'pref1',
type: 'boolean',
value: true
}, {
name: 'pref2',
type: 'boolean',
value: true
},
...
]
如何将第一个存储的偏好设置作为this._store.select('preferences')
的可观察链接?
我无法找到正确的语法,但我知道rxjs
有.first()
方法可用。我还没有找到一个很好的例子来说明我正在寻找的工作。
答案 0 :(得分:1)
这应该这样做:
this._store.select('preferences')
.filter((value, index) => index === 0)
答案 1 :(得分:0)
@Sasxa给出的答案几乎是完全正确的。这是我过去使用它的解决方案:
DestroyDB