baobab-react-resolver

2.0.3 • Public • Published

Build Status Coverage Status npm version

baobab-react-resolver

Promise resolver for Baobab + React powered applications.

Based on Baobab cursors.

Installation

npm install --save baobab baobab-react baobab-react-schemabranchmixin baobab-react-resolver

Example

import React from 'react';
import { ResolveMixin } from 'baobab-react-resolver';
import { SchemaBranchMixin } from 'baobab-react-mixins';
import { getDataFromApi } from 'api'
 
export default React.createClass({
  displayName: 'Component',
 
  mixins: [SchemaBranchMixin, ResolveMixin],
 
  schema: {
    response: {
      data: {
        count: 0,
      },
    }
  },
 
  getResolverBindings() {
    return [
      {
        cursor: this.cursors.response,
        service: getDataFromApi,
      },
    ];
  },
 
  render() {
    return (
      <div>
        {JSON.stringify({this.state.response})}
      </div>
    )
  },
});
 

Tests

npm test

Authors

2014-2017, beda.software

Package Sidebar

Install

npm i baobab-react-resolver

Weekly Downloads

5

Version

2.0.3

License

MIT

Last publish

Collaborators

  • ruscoder