Reputation: 1997
here's the scenario. i have this 2 different selectors which compose of different properties. what i want to happen is to combine them together which will be later on to be used as a parameters:
here's the codes:
@Injectable()
export class AuthenticationEffect {
getJwtToken$ = createEffect(() => {
return this.actions$.pipe(
ofType(TransactionIDActionTypes.LOAD_SUCCESS),
concatMap(action => of(action).pipe(withLatestFrom(
this.store.select(getTransactionIDSelector),
this.store.select(getAuthPayload)
))),
mergeMap(([, transactionId, authPayload]) => {
return this.authenticationService.getJwtToken(this.AuthenticateRequest(transactionId)).pipe(
map(response => {
return LoadSessionSuccess(response);
}),
catchError(error => of(LoadSessionError(error)))
);
})
);
});
constructor(private actions$: Actions, private store: Store<any>, private authenticationService: AuthenticateService) {}
AuthenticateRequest(transactionId): AuthenticateInterface {
return {
transactionId,
sourceIdentifier,
residentType,
organizationCode,
profile,
kycId,
identificationNumber,
mobileIdentifier,
nationality,
dateAcceptedTermsOfUse,
};
}
}
i need to execute this two selectors
this.store.select(getTransactionIDSelector), this.store.select(getAuthPayload)
at the same time, is this possible? and how do i get the state value for each selectors?
Upvotes: 0
Views: 242
Reputation: 15507
You can use concatLatestFrom
for this (instead of concatMap
in combination with withLatestFrom
).
...
concatLatestFrom(() => [
this.store.select(getTransactionIDSelector),
this.store.select(getAuthPayload)
]),
...
Upvotes: 1