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

[0.11] changes don´t bubble anymore?!? #433

Closed
indus opened this issue Sep 18, 2014 · 3 comments
Closed

[0.11] changes don´t bubble anymore?!? #433

indus opened this issue Sep 18, 2014 · 3 comments

Comments

@indus
Copy link

indus commented Sep 18, 2014

A simple example to illustrate my issue:

new Vue(
    {
        el: document.getElementById("somediv"),
        data: function () {
            return {
                pos: {
                    x: 10,
                    y: 11
                }
            }
        },
        ready: function () {

            this.$watch('pos', function (val) {
                // gets called in 0.10.6 val = {x:5,y:11} (if data is a object not a function)
                // BUT does not get called in 0.11
                console.log(val); 
            })

            this.$watch('pos.x', function (val) {
                // gets called val = 5
                console.log(val);   
            })

            this.$watch('pos.x+pos.y', function (val) {
                // gets called val = 16 (unusable value)
                console.log(val);   
            })

            this.$data.pos.x = 5;
        }
    });
@yyx990803
Copy link
Member

Yup, due to some internal changes, $watch now by default is a shallow watch. I just made some updates so you can do vm.$watch(exp, cb, true) to force a deep watch.

@indus
Copy link
Author

indus commented Sep 18, 2014

I thought the 'true' at the end should force an initial callback. But I will give it a try.

Maybe something like angulars $watchGroup or $watchCollection would be a solution, too.

By the way, you are a quick responder. Many thanks for your affort. I really like your work.

@yyx990803
Copy link
Member

Thanks :D
0.11's API is still (slightly) in flux before the release. I feel deep watching is a more frequent use case than immediate callback invocation, so the third argument is now deep watching and the fourth is immediate callback.

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

2 participants