meteor / react-packages

Meteor packages for a great React developer experience
http://guide.meteor.com/react.html
Other
573 stars 158 forks source link

Does ReactMeteorData support the use of Reference Equality? #159

Closed thesunny closed 3 years ago

thesunny commented 8 years ago

Sorry, I tried searching but could not find the answer to this and feel like it either should be part of the documentation (if ReactMeteorData supports reference equality) or should be considered for implementation (if it does not).

Let's say in getMeteorData you returns the results of a collection like say:

...
getMeteorData() {
  return {
    posts: Posts.find({}).fetch(),
    accounts: Accounts.find({}).fetch()
  }
}
...

Now let's say it returns 3 posts. Somebody (from a different session) updates the 3rd post.

My question is, can we reliably do reference equality (===) to determine that the first 2 posts are equal and the 3rd post is not equal in shouldComponentUpdate. This comparison would obviously be incredibly quick.

Further, if accounts is updated, can we do reference equality on posts to determine that the entire posts array has or hasn't changed.

It feels like this should be entirely possible given that Meteor ships only the changes from the server to the client. If no change is shipped on posts then use the same array. If there is a change in posts, then clone the Array and swap out the changed item with the new item.

It's unclear to me from an admittedly cursory look at the source code whether this is supported.

filipenevola commented 3 years ago

I'm closing this just because it's too old. We can open new issues for items that are still valid.