-
Notifications
You must be signed in to change notification settings - Fork 78
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
[CJS3] client single instance #599
Conversation
Size Change: +2.11 kB (0%) Total Size: 216 kB
|
|
||
expect(client1).to.equal(client2); | ||
expect(client2.key).to.eql('key2'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add following scenario to unit-test?
const client1 = StreamChat.getInstance('key2');
await client1.setUser({ id: 'vishal });
const client2 = StreamChat.getInstance('key3'); // or key2
await client2.setUser({ id: 'vishal });
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently if you call setUser twice, it throws following error:
'Use client.disconnect() before trying to connect as a different user. connectUser was called twice.'
But I think we should allow it if current user is same as id provided to setUser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed a test d2fcfc3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vishalnarkhede yea I actually put a comment in the PR description about this which is out of the scope of this PR. This is still an integration mistake but we can make it easier for users by not throwing error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahaa ... sorry missed it!!
Can we add it though ... seems like a simple check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea totally will open another PR on top of this one
Unfortunately Lots of TS boilerplates due to generics.
Potential Future improvements:
connectUser
can return the resolved promise for the second call instead of throwing an error if the user id in the token remains the same