Meteor’s subscription model works great but there are times where you may want to retrieve static, non-reactive data. Currently, Meteor does not have a documented way of doing this, but the pieces to do it are there.

But first, lets discuss why this is a good idea:

- you would use less resources compared to keeping an active subscription

- you may want to display a paginated list, where the data doesn’t change unless intended

- you may want to pre-load some kind of data just to cache it on the client

How To Do It

Since Meteor’s Collection.find().fetch() command returns an array of objects, all we need to do is create a method that would let us retrieve it on the client:

Meteor.methods({

getMenu: function (param1) {

var food = Food.find({'type': param1}).fetch();

return food;

}

});

Then on the client, you’d just have to run a Method call to retrieve the data and store it in a Session variable.

Meteor.call(“getMenu”, “burritos”, function (e, r) {

if (!e) {

Session.set(“menu”, r)

} else {

console.log(e);

}

});

Once you have that, you can use the Session variable anywhere, and re-run the Method’s you wish. It’s all reactive just like a subscription would be.

Another Way

Though its not broken, I didn’t find having such a large block of code pleasant to work with, so I created Fetcher to handle these situations.

It perform’s the same action as the Method call above but gives you a much cleaner API to work with:

Fetcher.retrieve(“menu”, “getMenu”, "burritos");

Since it builds off Meteor’s Reactive-Dict, you just use Fetcher.get(“menu”) to use the data anywhere in your application. My favorite part is that you can fit it all in just one line of code.

Conclusion

Even though Meteor is real-time and reactive, you can use it as a static framework to cut down on the overhead. Let me know what you think of this approach, and what you would like to see from the package.