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

fix(core): SlickEvent handler event should be type of ArgType #970

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/models/core.interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type SlickEventData } from '../slick.core';

export type Handler<ArgType = any> = (e: SlickEventData, args: ArgType) => void;
export type Handler<ArgType = any> = (e: SlickEventData<ArgType>, args: ArgType) => void;

export interface ElementEventListener {
element: Element | Window;
Expand Down
5 changes: 4 additions & 1 deletion src/models/rowDetailViewOption.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export interface OnRowDetailAsyncResponseArgs {

/** An explicit view to use instead of template (Optional) */
detailView?: any;

/** SlickGrid instance */
grid?: SlickGrid;
}

/** Fired when the async response finished */
Expand All @@ -112,7 +115,7 @@ export interface OnRowDetailAsyncEndUpdateArgs {
itemDetail: any;

/** Reference to the Slick grid object */
grid: SlickGrid;
grid?: SlickGrid;
}

/** Fired after the row detail gets toggled */
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/slick.rowdetailview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ export class SlickRowDetailView {
this.onAsyncResponse.notify({
item,
itemDetail: item,
detailView: item[`${this._keyPrefix}detailContent`]
detailView: item[`${this._keyPrefix}detailContent`],
grid: this._grid
}, undefined, this);
this.applyTemplateNewLineHeight(item);
this._dataView.updateItem(item[this._dataViewIdProperty], item);
Expand Down
4 changes: 2 additions & 2 deletions src/slick.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class SlickEvent<ArgType = any> {
* @param {Object} [scope] - The scope ("this") within which the handler will be executed.
* If not specified, the scope will be set to the <code>Event</code> instance.
*/
notify(args: ArgType, evt?: SlickEventData | Event | MergeTypes<SlickEventData, Event> | null, scope?: any) {
notify(args: ArgType, evt?: SlickEventData<ArgType> | Event | MergeTypes<SlickEventData<ArgType>, Event> | null, scope?: any) {
const sed: SlickEventData = evt instanceof SlickEventData
? evt
: new SlickEventData(evt, args);
Expand All @@ -216,7 +216,7 @@ export class SlickEvent<ArgType = any> {

// user can optionally add a global PubSub Service which makes it easy to publish/subscribe to events
if (typeof this._pubSubService?.publish === 'function' && this.eventName) {
const ret = this._pubSubService.publish<{ args: ArgType; eventData?: SlickEventData; nativeEvent?: Event; }>(this.eventName, { args, eventData: sed });
const ret = this._pubSubService.publish<{ args: ArgType; eventData?: SlickEventData<ArgType>; nativeEvent?: Event; }>(this.eventName, { args, eventData: sed });
sed.addReturnValue(ret);
}
return sed;
Expand Down