I have the following scenario
Load data if ain't loaded yet
this.mailFacade.mailLoaded$
.pipe(
filter(res => !res),
takeUntil(this.unsubscribe$)
)
.subscribe(_ => this.mailFacade.get());
this.userFacade.friendsLoaded$
.pipe(
filter(res => !res),
takeUntil(this.unsubscribe$)
)
.subscribe(_ => this.userFacade.getFriends());
this.onlineFacade.loaded$
.pipe(
filter(res => !res),
takeUntil(this.unsubscribe$)
)
.subscribe(_ => this.onlineFacade.get());
I tried to combine all with this
forkJoin([
this.mailFacade.mailLoaded$,
this.userFacade.friendsLoaded$,
this.onlineFacade.loaded$
]).pipe(
filter(([mail, user, online]) => !mail || !user || !online),
takeUntil(this.unsubscribe$)
)
.subscribe(([mail, user, online]) => {
if (!mail) { this.mailFacade.get(); }
if (!user) { this.userFacade.getFriends(); }
if (!online) { this.onlineFacade.get(); }
});
I wonder if it is the same, which will be the best implementation for this case?
i want to combine the loaded state but only filter for the data that ain't loaded yet
get() puts the state loaded to true
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…