-
-
Notifications
You must be signed in to change notification settings - Fork 29
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(core): expose all SlickEvent via internal PubSub Service #1311
Conversation
- it was already available for SlickGrid and SlickDataView SlickEvents but it wasn't yet available for other plugin events - adds a `getPubSubService()` method in SlickGrid to be able to easily get PubSub instance within any plugins or for the user themselves - Note: the internal PubSub can now deal with both regular PubSub events and SlickEvents but their structure are different 1. regular PubSub event have a structure of:: `((e: args: any) => ...` 2. SlickEvent have a different structure of:: `((e: { eventData: SlickEventData; args: any; }) => ...`
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1311 +/- ##
========================================
+ Coverage 95.7% 95.7% +0.1%
========================================
Files 198 198
Lines 21339 21358 +19
Branches 7095 7100 +5
========================================
+ Hits 20416 20435 +19
Misses 923 923 ☔ View full report in Codecov by Sentry. |
@zewa666 this might interest you... I added this for SlickGrid & SlickDataView when I created the new major but I forgot to add this approach to all plugins. The reason I added this was mainly for SlickGrid/SlickDataView because prior to this, I was looping through all of their events and was subscribing to all of them, if an SlickEvent was triggering, I was then rethrowing the event to my internal PubSub so that it could be used in frameworks like Angular-Slickgrid... but as you can imagine that had a lot of overhead, so this removes the overhead and also indirectly exposes them to the user if they wish to use them :) Most users probably won't use it since they typically subscribe from the View but sometime it might be useful to subscribe directly in the VM below is the overhead code I had prior to this new approach (lots of overhead) slickgrid-universal/packages/vanilla-bundle/src/components/slick-vanilla-grid-bundle.ts Lines 778 to 797 in 263bf13
|
this looks like a great api simplification. not directly affecting me for now but great to know |
SlickGrid
andSlickDataView
SlickEvent
s but it wasn't yet available for other plugin eventsgetPubSubService()
method in SlickGrid to be able to easily get PubSub instance from within any plugins or for the user themselvesSlickEvent
(because regular PubSub events do not include any native event), see example below((args: any) => ...
onBeforeGridCreate
((e: { eventData: SlickEventData; args: any; }) => ...
onSelectedRangesChanged
Example
So for example, the user can subscribe the event in multiple ways
CellSelectionModel
this.sgb.instances?.eventPubSubService
this.sgb.slickGrid?.getPubSubService()
)Cancel Event Bubbling
You can also cancel the event bubbling for some of the SlickEvent that supports it, for example the
onBeforeEditCell