Skip to content

Suggestion: setters on meteor data #51

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

Open
wildhart opened this issue Jan 2, 2019 · 0 comments
Open

Suggestion: setters on meteor data #51

wildhart opened this issue Jan 2, 2019 · 0 comments

Comments

@wildhart
Copy link

wildhart commented Jan 2, 2019

Since meteor reactive data are basically computed properties, it would be nice if they could also have setters so that they could be used natively inside v-model. e.g. It would be nice to do this:

meteor: {
    optedOut: {
        get() {
            return Meteor.user().optedOut;
        },
        set(value) {
            Meteor.call('setOptOut', value);
        },
    }
}

Instead of having to use $autorun inside computed like this:

computed: {
    optedOut: {
        get() {
            return this.$autorun(() => Meteor.user().optedOut);
        },
        set(value) {
            Meteor.call('setOptOut', value);
        },
    }
}

I know there's not much difference, but it took me a thorough reading of the documentation to learn about the $autorun function and using Meteor data without the meteor option. Whereas the getter and setter syntax seemed more natural to me and I was surprised that they weren't there when I looked for them in the docs. It would also keep all the meteor data together within the meteor block instead of split between meteor and computed.

Just a suggestion though - I'm loving this (and your other vue-meteor packages), thanks!

If you don't take this suggestion, then instead it would be good to use an example with a setter in your docs, so that users can find this functionality more easily in your docs.

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

1 participant