-
Notifications
You must be signed in to change notification settings - Fork 563
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
UserProvider and useUser #4557
UserProvider and useUser #4557
Conversation
const combinedConfigWithUser = | ||
user && !combinedConfig.sync?.user | ||
? mergeRealmConfiguration(combinedConfig, { sync: { user } }) | ||
: combinedConfig; |
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.
Would this simplification be possible?
const combinedConfigWithUser = | |
user && !combinedConfig.sync?.user | |
? mergeRealmConfiguration(combinedConfig, { sync: { user } }) | |
: combinedConfig; | |
const combinedConfigWithUser = mergeRealmConfiguration({ sync: { user } }, combinedConfig); |
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.
With this suggestion, it is possible for a non-sync application to have {sync: {user: undefined}} included in the configuration. But maybe there is a way to simplify this.
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.
const combinedConfigWithUser =
combinedConfig?.sync && user ? mergeRealmConfiguration({ sync: { user } }, combinedConfig) : combinedConfig;
This is a little simpler.
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.
it is possible for a non-sync application to have {sync: {user: undefined}}
Yeah, I figured this could be an edge-case and wondered if mergeRealmConfiguration
implemented a deletion of the sync
property if all members has undefined
values or something.
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.
That's perhaps another possibility
d1951b8
to
9187421
Compare
What, How & Why?
Add UserProvider and useUser hook to allow access to the user within any place in the application.
Note: There are no tests, as this is unreasonable to test without actually spinning up a BAAS server. This is an unrealistic expectation for this work and should be done in a greater effort to refactor tests. I have, however, throughly tested this with the example application. If we do start getting bugs, we should find a way to create regression tests.
We will also need a follow up PR to update the Realm dependency as soon as the new release is out, as this is dependent on the new App and User listener events.
This closes #4456
☑️ ToDos
Compatibility
label is updated or copied from previous entryBreaking
label has been applied or is not necessaryIf this PR adds or changes public API's: