Skip to content

Instantly share code, notes, and snippets.

if (Meteor.isClient) {
Meteor.subscribeReactive = function(name) {
var keyValues = {};
var mapper = Reactive[name].mapper;
var relations = Reactive[name].relations;
if (! mapper.key)
mapper.key = '_id';
Deps.autorun(function() {
// pass through object containing
# Making everything reactive!
#### The goal: Display the 10 latest `Books` along with their respective `Authors`
# Example 1.
> Authors are *not* reactive
> The problem with this approach is that once a new book (with a new author) appears,
> the new author is not sent to the client
```javascript
if (Meteor.isClient) {
Meteor.subscribeReactive = function(name) {
// ...
};
}
Meteor.Collection.prototype.relations = function(relations) {
this._relations = relations;
};
@dburles
dburles / gist:9086392
Last active August 29, 2015 13:56 — forked from tmeasday/gist:9086145
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() {
var debug = function(str) {
console.log('counter-cache: ' + str);
};
Meteor.Collection.prototype.maintainCountOf = function(collection, field, counterField) {
var self = this;
// what is Meteor.users an instanceof ?
// if (! (collection instanceof Meteor.Collection))
// throw new Error("Expected first parameter to be a Meteor Collection");
@dburles
dburles / gist:9302416
Created March 2, 2014 05:36
pub/sub pattern
//
// publish list of books (and authors)
//
Books.mainListCursor = function() {
return Books.find({}, { sort: { createdAt: -1 }, limit: 10 });
};
if (Meteor.isServer) {
Meteor.publish('books', function() {
<form id="filter">
{{#with profileFilter}}
<input type="text" name="nameFilter" value="{{search}}" placeholder="Filter users" />
<fieldset class="radio-fieldset">
<label>
<input type="radio" name="typeFilter" value="" {{typeSelected ''}} />
Show all
</label>
## Meteor Patterns ##
----------
# Simple Search
- Avoid duplicating the same query code on the client and server.
- Provide some simple search results.
> common/utils.js
## Meteor Patterns ##
----------
# 1. Simple Search
- Avoid duplicating the same query code on the client and server.
- Provide some simple search results.
> common/utils.js
## Meteor Patterns ##
----------
# 1. Simple Search
- Avoid duplicating the same query code on the client and server.
- Provide some simple search results.
> common/utils.js