meteorhacks:inject-data

v2.0.0Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

meteorhacks:inject-data

A way to inject data to the client with initial HTML

This is the package used by fast-render to push data to the client with the initial HTML.

Installation

meteor add meteorhacks:inject-data

Push Data

We need to use this package with a server side router. We've extended nodejs http.OutgoingMessage and provides an API like this.

Here is an example with picker.

1Picker.route("/", function(params, req, res, next) {
2  var ejsonData = {aa: 10};
3  InjectData.pushData(res, "some-key", ejsonData);
4  // make sure to move the routing forward.
5  next();
6});

Get Data

You can get data with the following API from the client.

1InjectData.getData("some-key", function(data) {
2  console.log(data);
3});