Closed
Description
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:
- Vue could allow iterating over custom objects, like Minimongo cursor; a plugin could register such custom object and a way to detect it
- Minimongo already provides some facilities to make reactivity work better, and knows how to inform consumer that documents moved in order, or which documents changed, instead of Vue having to figure out by comparing the new array of all documents with the previous array of all documents
- all documents in Minimongo have fixed known
_id
keys, so when usingv-for
on such cursor, that should be default:key
used
One 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:
- Registering post-processors for computed fields. In my case, a plugin would check if returned value is an instance of a cursor and then run on it
Object.freeze(cursor.fetch())
to convert cursor to array and prevent Vue replacing values with getters. - Registering a way to configure default key to iterate over. In my case, I could check that before the post-processor, that was a cursor, and set default key to iterate over to
_id
.
Metadata
Metadata
Assignees
Labels
No labels