Closed BradleyGoulding closed 7 years ago
Thanks for this fix. I was pulling my hair out as to why events such as "member_added" and "member_removed" weren't firing. this solved it.
Hey, this has affected me pretty badly, can we get a release out?
Sorry about the delay, done!
@jamiebikies you mind pushing v1.1.1 to NPM. We are using a workaround in our code right now but I would rather not use the hacky code but rather just use this.
Done @newdark
Wow thanks that so much
The Issue: Pusher unwire was never triggering the
pusher.unsubscribe(channelName);
(line 194) to unsubscribe form the channel. This is due tokeys(bindings[channelName].eventBindings).length
(line 193) not being equal to zero. This in turn is caused by theeventBindings.forEach
in line 180 being broken by the spliceeventBindings.splice(index, 1);
in line 185 resetting the index of the array. This means that for an array of length n the foreach loop runs (n-1) times resulting in a single item array every time.Current Code:
Proposed Fix
The general consensus on stackoverflow is that this kind of array loop needs to be done backwards, so that the item popped off the end does not affect the next index. As Ember foreach does not operate backwards, regular JS is needed.
the quickest method is using a
while(index--)
loop, after setting index to the length of the array, thus the following solution is idealI will look into submitting a PR to resolve this issue