Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor retryWithEscalation #179

Open
benjamincharity opened this issue May 17, 2018 · 0 comments
Open

Refactor retryWithEscalation #179

benjamincharity opened this issue May 17, 2018 · 0 comments
Assignees
Labels
Focus: utility General JS/TS utilities Needs: exploration Issues that need more information before being worked on Type: feature Functionality that doesn't currently exist

Comments

@benjamincharity
Copy link
Contributor

Current issues:

  1. It's functionally implemented in a way that is different from other operations on a stream (cognitive load).
  2. It requires duplicate items to be passed in every time it is used.
switchMap((action) => {
  return retryWithEscalation<ClaimMap>({
    tokenName: 'Linkedin',
    originalAction: action,
    httpSourceObservable: this.service.getRedirectUrl().pipe(
      take(1),
      map((response) => {
        return new RouterActions.Go({external: true, path: [response.callback_uri]});
      }),
    ),
    actions$: this.actions$,
  }).pipe(
    catchError(() => {
      return of(new FlashActions.CreateAction(linkedinDownFlashMessage));
    }),
  );
}),

Proposal

Rewrite as an injectable class:

switchMap((action) => {
  return this.service.getRedirectUrl().pipe(
      take(1),
      this.retryService.retryWithEscalation(action),
      map((response) => {
        return new RouterActions.Go({external: true, path: [response.callback_uri]});
      }),
    )
}),

retryWithEscalation kills stream and emits new action (this is the only way since all following operators need to consume what is emitted by retryWithEscalation).

The retry class will get the store and actions stream injected via it's constructor.

@benjamincharity benjamincharity self-assigned this May 17, 2018
@benjamincharity benjamincharity added Focus: utility General JS/TS utilities Needs: exploration Issues that need more information before being worked on Type: feature Functionality that doesn't currently exist labels May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus: utility General JS/TS utilities Needs: exploration Issues that need more information before being worked on Type: feature Functionality that doesn't currently exist
Projects
None yet
Development

No branches or pull requests

1 participant