-
-
Save dburles/9086392 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var relations = {}; | |
Meteor.Collection.prototype.relations = function(obj) { | |
relations[this._name] = obj; | |
}; | |
if (Meteor.isClient) { | |
Meteor.subscribeReactive = function(name) { | |
Meteor.subscribe(name); | |
Deps.autorun(function() { | |
// Meteor.subscribe(...) | |
}); | |
}; | |
} | |
if (Meteor.isServer) { | |
Cursor = Object.getPrototypeOf(new Meteor.Collection('_void').find()).constructor; | |
Cursor.prototype.join = function(name) { | |
this._joins = name; | |
return this; | |
}; | |
Meteor.publishReactive = function(name, fn) { | |
var cursor = fn(); | |
var collectionName = cursor._cursorDescription.collectionName; | |
Meteor.publish(name, function() { | |
return fn.apply(this, arguments); | |
}); | |
Meteor.publish(name + '_' + cursor._joins, function() { | |
return relations[collectionName][cursor._joins]; | |
}); | |
}; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment