0

I am using NgRx and Firestore and I am trying to figure a way to get the local store to stay synchronized with a firestore collection. I have an observable set up that fires when the firestore collection is updated, but in my reducer I'm not sure how to use the NgRx Entity adapter to replace what was in the store with the new data. I've tried addMany and upsertMany but they won't remove an item if it is deleted until the user refreshes.

The Reducer for my loadUsers Success Action looks like this

on(fromBatch.loadBatchesSuccess, (state: any, action: any) => ({...userAdapter.upsertMany(action.users, state), loaded: true, loading: false}))
mattc19
  • 678
  • 1
  • 11
  • 23

1 Answers1

1

Turns out it was right in front of me the whole time. userAdapter.addAll() will replace the current state with the array coming from the database.

mattc19
  • 678
  • 1
  • 11
  • 23