RxJS distinctUntilChanged - object comparsion

后端 未结 7 783
青春惊慌失措
青春惊慌失措 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:30

    Mehdi's solution although fast but wouldn't work if the order is not maintained. Using one of deep-equal or fast-deep-equal libraries:

    .distinctUntilChanged((a, b) => deepEqual(a, b))
    

提交回复
热议问题