I have 3 selectors in index.ts file
export const selectDetails = createSelector(
// some code
);
export const selectTransactionResponse = createSelector(
// some code
);
export const selectAdditionalDetails = createSelector(
// some code
);
These selectors work in the respective components where they are used. I have a use case where I need all this information in a new component and for this I write the following selector.
export const selectSnapshotData = createSelector(
selectDetails,
selectTransactionResponse,
selectAdditionalDetails,
(Details, transactionResponse, additionalDetails) => ({
additionalDetails,
Details,
transactionResponse
} as SnapshotData)
);
Now when I use this selector in my new component as follows:
this.store.pipe(
select(fromDetails.selectSnapshotData),
filter(snapshotData => !!snapshotData),
takeUntil(this.destroy$)).subscribe(snapshotData => {
console.log("Let's see how many times this is logged");
console.log(snapshotData);
});
The code inside subscribe is executed 3 times, once each when each of the pieces of information is loaded on the store.
What I want is for this method to be executed once when all the information has been made available. For that I tried using forkjoin in the component rather than writing a custom selector in index.ts but that doesn't work either.
So is there a way to do this?