-
Notifications
You must be signed in to change notification settings - Fork 577
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
Fix return type of App.allUsers
#5708
Conversation
public get allUsers(): Readonly<Record<string, User<FunctionsFactoryType, CustomDataType>>> { | ||
const result: Record<string, User<FunctionsFactoryType, CustomDataType>> = {}; | ||
for (const user of this.internal.allUsers) { | ||
result[user.identity] = User.get(user); | ||
} | ||
|
||
return result; | ||
} |
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.
Note: realm-web uses Object.fromEntries()
. Feel free to comment on what is preferred here.
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.
Lol - I just saw this now 🤦 If I have to choose, I probably like fromEntries
because it's shorter (fewer lines and doesn't need the type declared on result
) and I generally like a pure function over iterating and mutating an object (the result
in this case).
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.
Gotcha, despite the extra iteration from needing to create the array (.map
) passed to fromEntries
?
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.
LGTM
* main: (41 commits) allow useQuery to filter or sort a collection by using a callback (#5513) Fix `realm.create` types and 'requiredProperties' on Realm.Object constructor (#5697) Fix return type of `App.allUsers` (#5708) Removed renamed file Remove console.log Fix README instructions and bump version Bump template versions Update Templates (#5702) Moved "submodules" wireit task to "postinstall" Set up typedoc for realm-react, realm-web (#5709) Prepare for vNext (#5711) Prepare for 12.0.0-alpha.2 (#5707) Build iOS prebuilds in release by default (#5710) Use the event.sender as assignee when preparing release Updated prepare release workflow to print PR url in summary Fixing lint error fix the template app links (#5701) Expose `Sync` as named export (#5705) Enable all tests after bad rebase (#5595) Clear test state flag (#5689) ... # Conflicts: # packages/realm/src/Realm.ts
What, How & Why?
App.allUsers
was returning an array of users but now returns a record with theUser.id
as the key and theUser
as the value as the intended type.This closes #5671.
☑️ ToDos