Skip to content

Commit 71b690d

Browse files
Merge pull request #6 from qntln/fix/event-registering
Fix event resubscription
2 parents 025493b + 906224a commit 71b690d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-canvas",
3-
"version": "1.6.2",
3+
"version": "1.6.4",
44
"description": "High performance <canvas> rendering for React components",
55
"main": "dist/index.js",
66
"repository": {

src/CanvasComponent.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ export default class CanvasComponent {
1818
const subscriptions = this.subscriptions;
1919
const listeners = this.listeners;
2020

21+
let isListenerDifferent = false;
2122
if (listeners.get(type) !== listener) {
2223
listeners.set(type, listener);
24+
isListenerDifferent = true;
2325
}
2426

2527
if (listener) {
26-
if (!subscriptions.has(type)) {
28+
// Add subscription if this is the first listener of the given type
29+
// or the new listener is different from the current listener.
30+
if (!subscriptions.has(type) || isListenerDifferent) {
2731
subscriptions.set(type, this.node.subscribe(type, listener, this));
2832
}
2933
} else {

0 commit comments

Comments
 (0)