Comparison of objects is something we have to do often. Lodash is a good partner for this!

So I had to compare this observable, with my current data. Here is how I compare them:

import {isEqual} from 'lodash';

const results = isEqual(this.books.sort(), this.userBooks$.value.sort());
if (!results || (this.userBooks$.value.length === 0)) {
  this.userBooks$.next(this.books);
}

 

 

 

Saved you some valuable time?

Received 100 so far from 4 kind contributors.