Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Please expose Dep in Vue.util #5258

Closed
green-coder opened this issue Mar 23, 2017 · 5 comments
Closed

Please expose Dep in Vue.util #5258

green-coder opened this issue Mar 23, 2017 · 5 comments

Comments

@green-coder
Copy link

green-coder commented Mar 23, 2017

What problem does this feature solve?

This is for users who are implementing bridges between the reactivity of VueJS and external systems which manage their own data internally and which have their own reactivity system.

Giving a way to users to access Dep will allow them to define a dependency in a simple way. The use case is for defining changing values from other systems (mini-mongo's reactive queries, for instance) as dependencies in watched functions.

Currently, the users can only use defineReactive(), which means that there should be an object and a field for the dependency to exist. It is quite painful since the only thing needed is a const dep = new Dep() on which we would call depend() each time the external resource (function, db cursor, etc ...) changed.

What does the proposed API look like?

I propose to expose Dep in the object Vue.util.

@green-coder
Copy link
Author

For reference, Meteor has a dependency tracking system very similar to the one used in VueJS, and they expose their Tracker.Dependency class to the users on purpose :

Applications will find Tracker.autorun useful, while more advanced facilities such as Tracker.Dependency and onInvalidate callbacks are intended primarily for package authors implementing new reactive data sources.

I hope the same can be done on VueJS.

@gustojs
Copy link
Member

gustojs commented Mar 24, 2017

Just wondering, would this pull request #4652 fully satisfy the need of this particular issue?

@green-coder
Copy link
Author

You are totally right. I missed this PR when I did my search earlier. Thanks a lot!

@Gonzih
Copy link

Gonzih commented Nov 10, 2017

Can this be reopened since mentioned pull request was abandoned?

@mitar
Copy link
Contributor

mitar commented Feb 14, 2019

I made this package which exposes Dep and Watcher classes.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

5 participants