Skip to content

feat(signals): add Events plugin#4769

Merged
markostanimirovic merged 6 commits intomainfrom
feat/signals/events
May 9, 2025
Merged

feat(signals): add Events plugin#4769
markostanimirovic merged 6 commits intomainfrom
feat/signals/events

Conversation

@markostanimirovic
Copy link
Copy Markdown
Member

@markostanimirovic markostanimirovic commented Apr 30, 2025

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?

Closes #4580

What is the new behavior?

Events plugin has been added to the @ngrx/signals package.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 30, 2025

Deploy Preview for ngrx-site-v19 failed.

Name Link
🔨 Latest commit 01585bd
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-site-v19/deploys/681e678fe2712b00083f420f

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 30, 2025

Deploy Preview for ngrx-io canceled.

Name Link
🔨 Latest commit 01585bd
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/681e678f95ac50000832a1cd

Copy link
Copy Markdown
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

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

This is looking good! 🤘
I left a couple of questions.

To include it to the docs you'll to also have to update the following files:

  • projects/ngrx.io/tools/transforms/authors-package/api-package.js
  • projects/ngrx.io/tools/transforms/angular-api-package/index.js

Copy link
Copy Markdown
Contributor

@rainerhahnekamp rainerhahnekamp left a comment

Choose a reason for hiding this comment

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

Super! I've left a few comments.

Some of them may have already been discussed during the RFC, but they only became apparent to me once I started using it.

@markostanimirovic
Copy link
Copy Markdown
Member Author

Changes from the last commit:

  • Added additional tests
  • eventCreator and eventCreatorGroup functions are renamed back to event and eventGroup for simplicity
  • Event type is renamed to EventInstance to avoid naming conflict with the global Event type
  • Explicit payload property is used for events. This change significantly simplified the implementation:
    • There are no multiple types for event/event creators with and without payload (Event/EventWithProps and EventCreator/EventCreatorWithProps). Instead, there are only two types: EventInstance and EventCreator.
    • props and emptyProps helpers are deleted. type from the core @ngrx/signals package can be used to define the payload type
    • Runtime checks of the payload type are removed because they're not needed anymore
    • Runtime check when the event creator is accidentally dispatched instead of the event is removed - compilation error will be thrown instead
  • The second argument (state) is removed from the case reducer callback because a partial state updater can be returned.

Copy link
Copy Markdown
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

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

Nice work! 😎

Copy link
Copy Markdown
Contributor

@rainerhahnekamp rainerhahnekamp left a comment

Choose a reason for hiding this comment

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

Very good, just a minor issue with filenames and jsdoc for event(group) and the bigger one with including methods in withEffects

Copy link
Copy Markdown
Contributor

@rainerhahnekamp rainerhahnekamp left a comment

Choose a reason for hiding this comment

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

Wonderful. Good to go 🚀

@markostanimirovic markostanimirovic merged commit 980cf6f into main May 9, 2025
9 of 14 checks passed
@markostanimirovic markostanimirovic deleted the feat/signals/events branch May 9, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: Add events plugin to @ngrx/signals

3 participants