-
-
Notifications
You must be signed in to change notification settings - Fork 11
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: Events API #8
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8 +/- ##
==========================================
- Coverage 97.15% 96.92% -0.23%
==========================================
Files 31 32 +1
Lines 738 1008 +270
Branches 107 167 +60
==========================================
+ Hits 717 977 +260
- Misses 20 31 +11
+ Partials 1 0 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! This looks amazing. Just commented few styling things.
One another thing I want to discuss is how we get the results from the However, in Vuex ORM hooks, we need to know what user have returned. For example, if users return This discussion could be in different issue since this event api is pretty solid, though do you have any idea on this topic? |
I’ve opened this up for debate here #12. |
Great. Let's follow up the discussion over there. I'm gonna merge this since this looks pretty tasty 🥰 |
Type of PR:
Breaking changes:
Details
The Events API opens doors for better application hooks. This simple yet intelligent API is designed with Typescript in mind. It attempts to solve, but not limited to, the following pitfalls of a typical hook system:
new Events<MyEvents>
this
contextUsage
Define event interfaces using keys & argument tuples.
Instantiate the Events object with the events interface.
Add or remove listeners.
Add one-time listeners which are removed on the next broadcast event.
Subscribe to all events.
Emit events.
Noteworthy
The Events API is designed to emit events with payloads to listeners and subscribers. If the API is offered to authors within the ecosystem and general user-land, performance and optimisation plays a key role as the use-cases can be unprecedented. To cater for these needs, the following applies:
Object.create(null)
to increase operation cycles.removeAllListeners(event: string)
is a protected method to prevent side-effects from user-land intervention.