Skip to content
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

adds fetchAsync to useFindServer #360

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/react-meteor-data/useFind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const checkCursor = <T>(cursor: Mongo.Cursor<T> | Partial<{ _mongo: any, _cursor
!(cursor._mongo && cursor._cursorDescription)) {
console.warn(
'Warning: useFind requires an instance of Mongo.Cursor. '
+ 'Make sure you do NOT call .fetch() on your cursor.'
+ 'Make sure you do NOT call .fetch() or .fetchAsync() on your cursor.'
);
}
}
Expand Down Expand Up @@ -129,6 +129,11 @@ const useFindServer = <T = any>(factory: () => Mongo.Cursor<T> | undefined | nul
Tracker.nonreactive(() => {
const cursor = factory()
if (Meteor.isDevelopment) checkCursor(cursor)

if (cursor?.fetchAsync) {
return cursor.fetchAsync()
}
Comment on lines +133 to +135
Copy link
Member

@henriquealbert henriquealbert Jul 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you update the warning here to add the fetchAsync in here as well?

+ 'Make sure you do NOT call .fetch() on your cursor.'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning updated, thanks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't we need await somewhere around here?


return cursor?.fetch?.() ?? null
})
)
Expand Down