Skip to content

Easy subscriptions and reactive queries for Vue and Meteor

Notifications You must be signed in to change notification settings

Akryum/vue-meteor-data

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

#Vue Meteor Data

##Easy subscriptions and reactive queries for Vue and Meteor

When a view is created, the mixin iterates through your reactive data and wraps it individually in Vue's vm.$watch. Then each of these wrappers are wrapped in Meteor's Tracker.autorun.

####Installation

var VueMeteorData = require ('vue-meteor-data')
Vue.mixin(VueMeteorData)      

####Usage example 1

module.exports = {  
    reactiveData   : {
        tasks: function () {
            return Tasks.find().fetch()
        }
    },
    created: function(){
        this.subscribe('tasks/all')
    }
}    

####Usage example 2

module.exports = {
    created: function(){
        this.subscribe('tasks/all')
        this.autorun(function(){
            this.$set('tasks', Tasks.find().fetch())
        }.bind(this))
    }
}

####Usage example 3 with VueRouter

module.exports = {  
    reactiveData   : {
        tasks: function () {
            return Tasks.find(this.$route.params.id).fetch()
        }
    },
    created: function(){
        this.subscribe('tasks/all')
    }
}

####Usage example 4

module.exports = {  
    reactiveData   : {
        tasks: function (vm) {
            console.log(vm === this) //returns true
        }
    }
}

About

Easy subscriptions and reactive queries for Vue and Meteor

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%