Skip to content

Latest commit

History

History
63 lines (52 loc) 路 2.1 KB

fast-render-integration.md

File metadata and controls

63 lines (52 loc) 路 2.1 KB

Fast-Render Integration

To get the most out of Flow-Router Extra and Fast-Render use combination of subscriptions and waitOn.

Install fast-render library:

meteor add communitypackages:fast-render

Note: make sure communitypackages:fast-render placed above ostrio:flow-router-extra in meteor-app/.meteor/packages file. For package developers: Make sure communitypackages:fast-render placed before ostrio:flow-router-extra in api.use() method:

# meteor-app/.meteor/packages
communitypackages:fast-render
ostrio:flow-router-extra
// meteor-package/package.js
Package.onUse((api) => {
  api.use(['communitypackages:fast-render', 'ostrio:flow-router-extra', /*...*/]);
});

To utilize features of Fast-Render place routes definition into lib or any other isomorphic location/import.

// meteor-app/lib/routes.js
import { Meteor }     from 'meteor/meteor';
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';

FlowRouter.route('/:_id', {
  name: 'file',
  action(params, queryParams, data) {
    // this.render(/*...*/);
  },
  waitOn(params) {
    if (Meteor.isClient) {
      return Meteor.subscribe('data', params._id);
    }
  },
  subscriptions(params) {
    if (Meteor.isServer) {
      this.register('data', Meteor.subscribe('data', params._id));
    }
  },
  fastRender: true,
  data(params) {
    // Get subscribed data
    return MyCollection.findOne(params._id) || false;
  }
});

Further Reading