Skip to content

Commit

Permalink
fix: derive the arguments of callback function
Browse files Browse the repository at this point in the history
  • Loading branch information
wewoor committed Dec 11, 2020
1 parent cdf8388 commit bccae6e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/services/workbench/activityBarService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface IActivityBarService extends Component<IActivityBar> {
* Add click event listener
* @param callback
*/
onClick(callback: (key: React.MouseEvent) => void);
onClick(callback: (key: React.MouseEvent, item: IActivityBarItem) => void);
onSelect(callback: (key: React.MouseEvent, item: IActivityBarItem) => void);
}

Expand Down Expand Up @@ -63,15 +63,14 @@ export class ActivityBarService
public onSelect(
callback: (key: React.MouseEvent, item: IActivityBarItem) => void
) {
this.subscribe(ActivityBarEvent.Selected, (args) => {
const key = args[0];
const item: IActivityBarItem = args[1];
this.subscribe(ActivityBarEvent.Selected, (key, data) => {
const item: IActivityBarItem = data;
if (item.type !== 'global') {
this.updateState({
selected: key,
});
}
if (callback) callback(key, item);
callback?.(key, item);
});
}
}

0 comments on commit bccae6e

Please sign in to comment.