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(events): Remove orphaned event when annotator is destroyed #680

Merged
merged 1 commit into from
Feb 25, 2021
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
5 changes: 3 additions & 2 deletions src/common/BaseAnnotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class BaseAnnotator extends EventEmitter {
this.addListener(LegacyEvent.SCALE, this.handleScale);
this.addListener(Event.ACTIVE_SET, this.handleSetActive);
this.addListener(Event.ANNOTATION_REMOVE, this.handleRemove);
this.addListener(Event.COLOR_SET, this.handleColorSet);
this.addListener(Event.COLOR_SET, this.handleSetColor);
this.addListener(Event.VISIBLE_SET, this.handleSetVisible);

// Load any required data at startup
Expand All @@ -132,6 +132,7 @@ export default class BaseAnnotator extends EventEmitter {
this.removeListener(LegacyEvent.SCALE, this.handleScale);
this.removeListener(Event.ACTIVE_SET, this.handleSetActive);
this.removeListener(Event.ANNOTATION_REMOVE, this.handleRemove);
this.removeListener(Event.COLOR_SET, this.handleSetColor);
this.removeListener(Event.VISIBLE_SET, this.handleSetVisible);
}

Expand Down Expand Up @@ -218,7 +219,7 @@ export default class BaseAnnotator extends EventEmitter {
this.setVisibility(visibility);
};

protected handleColorSet = (color: string): void => {
protected handleSetColor = (color: string): void => {
this.setColor(color);
};

Expand Down
1 change: 1 addition & 0 deletions src/common/__tests__/BaseAnnotator-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ describe('BaseAnnotator', () => {

expect(annotator.removeListener).toBeCalledWith(Event.ACTIVE_SET, expect.any(Function));
expect(annotator.removeListener).toBeCalledWith(Event.ANNOTATION_REMOVE, expect.any(Function));
expect(annotator.removeListener).toBeCalledWith(Event.COLOR_SET, expect.any(Function));
expect(annotator.removeListener).toBeCalledWith(Event.VISIBLE_SET, expect.any(Function));
expect(annotator.removeListener).toBeCalledWith(LegacyEvent.SCALE, expect.any(Function));
});
Expand Down