Skip to content

Commit

Permalink
Merge pull request #256 from GetStream/vishal/remove-event-listener
Browse files Browse the repository at this point in the history
Allow .off() on uninitialized channels
  • Loading branch information
vishalnarkhede authored Feb 13, 2020
2 parents 6889596 + 7ad89b5 commit 985155f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ export class Channel {
*
*/
off(callbackOrString, callbackOrNothing) {
this._checkInitialized();
const key = callbackOrNothing ? callbackOrString : 'all';
const valid = isValidEventType(key);
if (!valid) {
Expand Down
17 changes: 17 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,23 @@ describe('Chat', function() {
);
}
});

it('should allow .off() on unwatched channels', () => {
const client = getTestClient(false);
const userID = uuidv4();

client.setUser({ id: userID }, createUserToken(userID));
const channel = client.channel('messaging', uuidv4());
let result;
try {
channel.off('message.new');
result = true;
} catch (e) {
result = false;
}

expect(result).to.be.ok;
});
});

describe('Channel State', function() {
Expand Down

0 comments on commit 985155f

Please sign in to comment.