ngneat / effects

🪄 A framework-agnostic RxJS effects implementation
https://www.netbasal.com
MIT License
63 stars 11 forks source link

Multiple improvements in typings and current `Actions` API and new API for angular environment providers #39

Closed EricPoul closed 1 year ago

EricPoul commented 1 year ago

PR Checklist

Please check if your PR fulfills 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?

Issue Number: N/A

What is the new behavior?

  1. Added an ability to dispatch multiple actions per one call.
  2. dispatch method and createEffect function are now strictly typed.
  3. Added new operator toProps and made toPayload work only with payloads.
  4. Added new functions to provide effects in Angular:
    • provide provideEffectsManager(config?) in the root.
    • provide provideEffects(EffectOne, EffectTwo) in any environment providers.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Other information

stackblitz[bot] commented 1 year ago

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

EricPoul commented 1 year ago

@NetanelBasal when we agree on everything I'll update docs.

EricPoul commented 1 year ago

Also, I gave up implementing component effects since we don't have a hook while the component injector creating, like ENVIRONMENT_INITIALIZER to trigger it to subscribe on all effects under the hood.

NetanelBasal commented 1 year ago

@EricPoul, thanks for the PR. It'll be helpful if you can summarize the changes before I review them.

EricPoul commented 1 year ago

I added info to the What is the new behavior? block. Or I can give more explicit info.

NetanelBasal commented 1 year ago

Yes, it's fine, I've missed it.

NetanelBasal commented 1 year ago

Also, I gave up implementing component effects since we don't have a hook while the component injector creating.

We can leverage the hostDirectives features, but I'm wondering if it'll be "to abuse it".

EricPoul commented 1 year ago

We can leverage the hostDirectives features, but I'm wondering if it'll be "to abuse it".

It might work. I'll give it a try separately from this pr.