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

Why fetch in composer? #90

Open
merlinstardust opened this issue Mar 31, 2016 · 6 comments
Open

Why fetch in composer? #90

merlinstardust opened this issue Mar 31, 2016 · 6 comments

Comments

@merlinstardust
Copy link

Why is fetch being used in the composer functions?
Doesn't fetch return a non-reactive array?

Why not just return a cursor?

@arunoda
Copy link
Contributor

arunoda commented Mar 31, 2016

Could you give more context to this ?

@merlinstardust
Copy link
Author

In core/containers/postlist.js, there is this line

const posts = Collections.Posts.find().fetch();

@arunoda
Copy link
Contributor

arunoda commented Mar 31, 2016

That's the way we do it. We called .find() here. So, whenever there's a change inside to the collection, you'll get data.

@merlinstardust
Copy link
Author

But why not just do it without the fetch?

const posts = Collections.Posts.find();

To me, it seems like fetch would become inefficient for large sets of data because it's returning all the data at once.

@arunoda
Copy link
Contributor

arunoda commented Mar 31, 2016

This is not possible with React. This is only something works in Blaze.
Have you done a performance test?
Usually this won't be an issue in React.

@newswim
Copy link

newswim commented May 20, 2016

Fetch assigns dependencies and is in fact reactive. From the docs:

Cursors are a reactive data source. On the client, the first time you retrieve a cursor’s documents with fetch, map, or forEach inside a reactive computation (eg, a template or autorun), Meteor will register a dependency on the underlying data. Any change to the collection that changes the documents in a cursor will trigger a recomputation. To disable this behavior, pass {reactive: false} as an option to find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants