RxJS distinctUntilChanged - object comparsion

后端 未结 7 834
青春惊慌失措
青春惊慌失措 2021-01-03 20:57

I have stream of objects and I need to compare if current object is not same as previous and in this case emit new value. I found distinctUntilChanged operator should do exa

7条回答
  •  死守一世寂寞
    2021-01-03 21:43

    If you change the value mutably, none of the other answers work. If you need to work with mutable data structures, you can use distinctUntilChangedImmutable, which deep copies the previous value and if no comparison function is passed in, will assert that the previous and the current values deep equals each other (not === assertion).

提交回复
热议问题