mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fixed an issue where a rehydrate would sometimes leave the app in a broken state
This commit is contained in:
@@ -36,8 +36,16 @@ export function boot(cache: TransferState, appRef: ApplicationRef, store: Store<
|
||||
// authentication mechanism goes here
|
||||
return () => {
|
||||
appRef.isStable.filter((stable: boolean) => stable).first().subscribe(() => {
|
||||
cache.inject();
|
||||
});
|
||||
// isStable == true doesn't guarantee that all dispatched actions have been
|
||||
// processed yet. So in those cases the store snapshot wouldn't be complete
|
||||
// and a rehydrate would leave the app in a broken state
|
||||
//
|
||||
// This setTimeout without delay schedules the cache.inject() to happen ASAP
|
||||
// after everything that's already scheduled, and it solves that problem.
|
||||
setTimeout(() => {
|
||||
cache.inject();
|
||||
}, 0);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user