error TS2339: Property 'partition' does not exist on type 'Observable<boolean>'

半世苍凉 提交于 2019-12-05 19:53:45

After seeing github conversion

I think we should deprecate the partition operator and remove it for v7.

Reasons:

  • Not really an operator: partition isn't really an "operator" in that it returns [Observable, Observable] rather than Observable. This means it doesn't compose via pipe like the others.

  • Easy to replace with filter: partition is easily replaced with the much more widely known filter operator. As partition is effectively the same thing as: const partition = (predicate) => [source.pipe(filter(predicate)), source.pipe(filter((x, i) => !predicate(x, i)))]

in your case:

import {filter} = "rxjs/operators"
const source = this.store.select(state => state.tetris.isTiming);
const partition = (predicate) => [source.pipe(filter(predicate)), source.pipe(filter((x, i) => !predicate(x, i)))]

const [isTiming$, isNotTiming$] = partition(value => value);
  • Rarely used: It's little used, by any code survey I've taken (within thousands of lines of code that I know use RxJS)

I guest you should use Observable method pipe, something like this :

const [isTiming$, isNotTiming$] = this.store.select(state => state.tetris.isTiming)
        .pipe(
            partition(value => value);
        )
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!