A
A
Anton2015-09-20 17:44:52
JavaScript
Anton, 2015-09-20 17:44:52

Meteor + polymer without blaze?

I am trying to use meteor + polymer without blaze templates.
I wrote this behavior:

MeteorBehavior = {

        properties: {
            isReady: {
                type: Boolean,
                value: false,
                notify: true
            },
            currentUser: {
                type: Object,
                value: null,
                notify: true
            }
        },

        ready: function () {
            var self = this;
            var subCount = 0;
            self.subscriptions.forEach(function(itm){
                itm = $.type(itm) == 'array' ? itm : [itm];
                itm[itm.length] = function () {
                    subCount++;
                    self.isReady = subCount >= self.subscriptions.length;
                };
                Meteor.subscribe.apply(null, itm);
            });

            Meteor.startup(function () {
                Tracker.autorun(function(){
                    self.currentUser = Meteor.user();
                });
                Tracker.autorun(self.autorun.bind(self));
            });
        },

        subscriptions: [],

        autorun: function() {
        }

    };

and use it:
(function () {
        Polymer({
            is: 'posts-list',

            posts: [],

            behaviors: [MeteorBehavior],

            autorun: function(){
                this.posts = Posts.find().fetch();
            },

            subscriptions: ['posts']

        });
    })();

Is this a good decision? And how to animate data changes without uihooks?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Izmailov, 2015-09-20
@WapGeaR

Here's a tip for you, Antokh:
https://github.com/meteor/meteor/issues/2765 so everything is there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question