-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Allow extending iterating over custom objects in v-for #6079
Comments
Now I am realizing, probably post-processor is not a good idea because it is not that |
What's the difference with #5893 ? |
This issue is asking to allow iteration over custom objects, not array-like things. Especially to be able to specify multiple other things: maybe better integrate with reactivity (so that this object could inform vue how values changed, like order modified, or one particular item in the array changed and not others), maybe allow custom conversion to array-like (or array) object for the rest of the code, and to explain which key to use to iterate. In some way it is to help make plugins which allow developers to return any object and it will convert them to array-like (or array), instead of asking developers to pass array-like objects. It could also be seen just as sugar on top. |
Post processors is something that can be done directly inside of the computed property, so I really don't see what's the gain
We prefer having explicit |
Yes, it would be mostly a sugar so that one does not have to manually convert to an array-like object every time you make a query. It is so that it is more similar to how Blaze works and people are used to.
:-( I understand that in general any magic is tricky here. But in the case of Minimongo it is pretty clear what the key should be. |
In that case, we're going to pass because adding postprocessors to computed properties is something that you should be doing yourself and the extra api is not worth the cost. Keep in mind this can be added with a plugin that parses computed properties and add the extra post process |
That's what I wanted to hear. Any link to an example of such plugin? |
One issue is also that I am realizing, that post-processing is maybe not the best approach. As I wrote above:
So, is there a way to do pre-processing for |
Not that I'm aware of, but using a mixin with a
That would be a computed property |
Note the "only* part. Because that computed property can also be used for other purposes, not just |
we won't add something for |
What problem does this feature solve?
I am working on fully integrating Vue with Meteor. I managed to implement it fully, except for how Vue integrates with Minimongo, a MongoDB-compatible client-side reactive datastore. One can run MongoDB queries against a client-side database, for which you receive a cursor. Now, ideally, one could use such cursor directly in Vue.
So, I see few potential improvements here:
_id
keys, so when usingv-for
on such cursor, that should be default:key
usedOne downside of Minimongo is that every time you request objects from it, or even cursor, you get copies of objects, referentially non-equal.
What does the proposed API look like?
While there are potentially better ways to integrate Minimongo's support for reactivity hooks, I think the simplest and more general way would be for Vue to allow:
Object.freeze(cursor.fetch())
to convert cursor to array and prevent Vue replacing values with getters._id
.The text was updated successfully, but these errors were encountered: