This package has been deprecated

Author message:

DO NOT USE. Functionality merged into marko-async.

raptor-data-providers

1.0.1-beta • Public • Published

raptor-data-providers

The raptor-data-providers module provides support for the more efficient and simpler "Pull Model "approach to providing templates with view model data.

  • Push Model: Request all needed data upfront and wait for all of the data to be received before building the view model and then rendering the template.
  • Pull Model: Register data providers and immediately start rendering the template. Let the template pull the data needed during rendering.

The Pull Model approach to template rendering requires the use of a templating engine that supports asynchronous template rendering (e.g. raptor-templates and dust). This is because before rendering the template begins not all of data may have been fully retrieved. Parts of a template that depend on data that is not yet available are rendered asynchronously with the Pull Model approach.

Push Model versus Pull Model

The problem with the traditional Push Model approach is that template rendering is delayed until all data has been fully received. This reduces the time to first byte, and it also may result in the server sitting idle while waiting for data to be loaded from remote services. In addition, if certain data is no longer needed by a template then only the template needs to be modified and not the controller.

With the new Pull Model approach, template rendering begins immediately. In addition, fragments of the template that depend on data from data providers are rendered asynchronously and wait only on the associated data provider to complete. The template rendering will only be delayed for data that the template actually needs.

Simple Example

Register data providers upfront:

require('raptor-data-providers').register({
    weather: function(args, callback) {
        var zipcode = args.zipcode;
        weatherService.getWeather({
                zipcode: zipcode
            },
            callback);
    });

Readme

Keywords

none

Package Sidebar

Install

npm i raptor-data-providers

Weekly Downloads

2

Version

1.0.1-beta

License

Apache License v2.0

Last publish

Collaborators

  • austinkelleher
  • dylanpiercey
  • mlrawlings
  • pnidem
  • philidem