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

feat(effects): make resubscription handler overridable #2295

Merged
merged 3 commits into from
Jan 27, 2020

Conversation

zakhenry
Copy link
Contributor

@zakhenry zakhenry commented Dec 18, 2019

PR Checklist

Please check if your PR fulfils the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Behavior of resubscription to closed observables is not configurable

Closes #2294

What is the new behavior?

Behavior of resubscription to closed observables is now configurable by injecting a substitute implementation.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Impact is relatively low - it is a simple rename of a field that was introduced in v8. See @alex-okrushko's comment - he found nowhere in google that is using this feature yet.

Migration path is a simple rename, an automated migration with a schematic is theoretically possible (I've not done this before but willing to learn).

@ngrxbot
Copy link
Collaborator

ngrxbot commented Dec 18, 2019

Preview docs changes for f2e40f2 at https://previews.ngrx.io/pr2295-f2e40f2/

@zakhenry zakhenry force-pushed the feat/customisable-error-handling branch 2 times, most recently from 13b52ab to b3f2aa1 Compare December 18, 2019 19:53
@zakhenry zakhenry marked this pull request as ready for review December 19, 2019 10:40
@zakhenry zakhenry force-pushed the feat/customisable-error-handling branch 2 times, most recently from c497db3 to 35ffbcc Compare December 19, 2019 12:01
@brandonroberts
Copy link
Member

Closing this along with #2294

@zakhenry
Copy link
Contributor Author

@brandonroberts would you mind reopening this PR please given #2294 was reopened?

@zakhenry zakhenry force-pushed the feat/customisable-error-handling branch from 35ffbcc to 1970330 Compare January 12, 2020 23:42
@zakhenry zakhenry changed the title WIP: feat(effects): make resubscription handler overridable feat(effects): make resubscription handler overridable Jan 12, 2020
CHANGELOG.md Outdated Show resolved Hide resolved
@zakhenry zakhenry force-pushed the feat/customisable-error-handling branch from 1970330 to 6e6ca22 Compare January 12, 2020 23:49
Copy link
Member

@alex-okrushko alex-okrushko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong, if we set EFFECTS_ERROR_HANDLER in any of the modules, it would override the default effects error handle for all the effects classes.

I think we need something that we can pass to a particular EffectsModule either forRoot or forChild and it would apply only to that group of Effects. WDYT?

docs/effects/api.md Outdated Show resolved Hide resolved
docs/effects/api.md Outdated Show resolved Hide resolved
modules/effects/spec/effects_error_handler.spec.ts Outdated Show resolved Hide resolved
modules/effects/spec/effects_error_handler.spec.ts Outdated Show resolved Hide resolved
modules/effects/spec/effects_error_handler.spec.ts Outdated Show resolved Hide resolved
modules/effects/spec/effects_error_handler.spec.ts Outdated Show resolved Hide resolved
@zakhenry zakhenry force-pushed the feat/customisable-error-handling branch 3 times, most recently from d3ce151 to 1a7771c Compare January 13, 2020 08:16
@zakhenry
Copy link
Contributor Author

Correct me if I'm wrong, if we set EFFECTS_ERROR_HANDLER in any of the modules, it would override the default effects error handle for all the effects classes.

I think we need something that we can pass to a particular EffectsModule either forRoot or forChild and it would apply only to that group of Effects. WDYT?

@alex-okrushko Hmmm this is an interesting thought - I'm not sure that I'm convinced that the effects grouping is the level that developers would want to customise the behaviour, because at that point they would have limited ability to customise the behavior on a per-class basis.

Perhaps the better solution to address that case would be to (maybe later) introduce a new hook, and if developers desire grouping within a module it could be done through inheritance or a custom decorator if they so choose.

e.g.

class MyEffects implements EffectErrorHandler {

   ngrxEffectErrorHandler(action$: Observable<Action>, errorHandler: ErrorHandler) {
     // ...
   }

   effect$ = createEffect(...);

}

This would be more expected IMO considering similar control behavior with OnRunEffects being class hook based.

@zakhenry zakhenry force-pushed the feat/customisable-error-handling branch from 1a7771c to ce04423 Compare January 13, 2020 11:54
@alex-okrushko
Copy link
Member

This is still on my radar - will try to get some time to review it tomorrow.

@zakhenry
Copy link
Contributor Author

@alex-okrushko yea no problem, whenever is fine

@zakhenry zakhenry force-pushed the feat/customisable-error-handling branch 2 times, most recently from 9869378 to 6a240c0 Compare January 19, 2020 18:05
BREAKING CHANGE:
`resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata

Closes ngrx#2294
…DLER non optional, moving provider up to EffectsModule
Copy link
Member

@alex-okrushko alex-okrushko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on it 👍

Migration path is a simple rename, an automated migration with a schematic is theoretically possible (I've not done this before but willing to learn).

Let's look into that as well - in another PR :)

projects/ngrx.io/content/guide/effects/lifecycle.md Outdated Show resolved Hide resolved
docs/effects/api.md Outdated Show resolved Hide resolved
modules/effects/spec/effects_error_handler.spec.ts Outdated Show resolved Hide resolved
modules/effects/src/effects_resolver.ts Outdated Show resolved Hide resolved
projects/ngrx.io/content/guide/effects/lifecycle.md Outdated Show resolved Hide resolved
projects/ngrx.io/content/guide/effects/lifecycle.md Outdated Show resolved Hide resolved
modules/effects/src/tokens.ts Show resolved Hide resolved
modules/effects/src/effect_sources.ts Show resolved Hide resolved
@timdeschryver
Copy link
Member

I like the API this PR provides, good job 👍

Migration path is a simple rename, an automated migration with a schematic is theoretically possible (I've not done this before but willing to learn).

Yes, this is possible and should be a simpler one.
If you want I can grab this one after this PR lands, or assist you in making a PR - the choice is yours 🙂

@zakhenry zakhenry force-pushed the feat/customisable-error-handling branch from 674a7c5 to 25d8ad7 Compare January 25, 2020 16:27
@zakhenry
Copy link
Contributor Author

@timdeschryver thanks, I'm going to take a crack at the migration PR, I'll let you know if/when I need a hand. I've got the basics working already, just need to narrow the visitor so it's not just doing a dangerous global find/replace. I'll open the PR this weekend to discuss over. I'll keep this PR for the actual change 👍

@zakhenry zakhenry force-pushed the feat/customisable-error-handling branch from 25d8ad7 to f2e40f2 Compare January 25, 2020 21:27
@brandonroberts brandonroberts merged commit 3a9ad63 into ngrx:master Jan 27, 2020
@zakhenry zakhenry deleted the feat/customisable-error-handling branch January 27, 2020 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Ability to customise resubscribeInCaseOfError functionality to allow for user interaction with errors
6 participants