Closed randallmeeker closed 3 years ago
As far as I can tell the code does not actually reset the store when reset: true
is set, but attempts to update the store with merging an empty array with the current state object???.
Instead I would think that we should be running the akita's resetStore action?
This is based on staring at the code for like 30 minutes so I easily may have misjudged something.
Pinging @Benny739 as they authored the reset code and my offer some insight?
I have updated my guard to reset manually for now.
@Injectable({ providedIn: 'root' })
export class SitesGuard extends CollectionGuard<SiteState> {
constructor(service: SiteService, private store: SiteStore) {
super(service);
}
// Sync and set active
sync(next: ActivatedRouteSnapshot): Observable<any> {
this.store.reset(); // <== HAVE TO ADD THIS HERE
return this.service.syncCollection({
params: {
orgId: next.params.orgId,
projectId: next.params.projectId,
},
reset: true, <=== THIS DOES NOTHING
});
}
}
Hey, thanks for reporting. There was a reason why we patched the store with an empty array rather then resetting it. But I can't remember why and obviously it doesn't work. I did a PR which now uses the reset func from akita
https://github.com/dappsnation/akita-ng-fire/pull/168 you can try it out with version v4.0.1 . The critical change for version 4 is that you need to use firebase v8. If that is a problem for you let me know, I can publish a different v3 for you.
I appreciate this. Currently I am stuck on V3 as you suspected.
I pushed version 3.1.8 . Let me know if it worked for you
I have a guard setup to reset collection on sync, however restet does not appear to be working. The store does not reset when the sync starts and I have all the old records from the previous sync. Is this setup correctly to remove all the current records when starting a new sync?
v. 3.1.6
Store
Service
Guard