LoginSignup
0
0

More than 5 years have passed since last update.

MeteorのTraker.autorunがClientでしか動かない問題をなんとかしたい

Last updated at Posted at 2014-12-21

MeteorのTracker.autorunはとても便利なんですが、
clientでしか動かないため、server内で処理させたい場合どうすればいいんでしょうか?

curser.observeを使う

大概の場合はCollectionの変更を検知して何かを実行させたいというパターンですので以下で対処します。

server/autorun.js

Meteor.startup(function(){
    Players.find().observe(
        {
            'changed': function (oldDocument,newDocument) {
                console.log("player changed!!");
                //何かServerにさせたい処理をここに書く
                Meteor.call("sendAppleNotifications");
            }
        }
    );

});

そもそもTracker.autorunがanywhereだったらよかったのに・・・。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0