├── .gitignore
├── main.js
├── with-data.js
├── package.js
├── with-method-data.js
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .versions
2 |
--------------------------------------------------------------------------------
/main.js:
--------------------------------------------------------------------------------
1 | import withData from './with-data'
2 | import withMethodData from './with-method-data'
3 |
4 | export {
5 | withData,
6 | withMethodData
7 | }
8 |
--------------------------------------------------------------------------------
/with-data.js:
--------------------------------------------------------------------------------
1 | import {createContainer} from 'meteor/react-meteor-data'
2 |
3 | export default function (getMeteorData, opts) {
4 | return function (ComposedComponent) {
5 | return createContainer(Object.assign({ getMeteorData }, opts), ComposedComponent)
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/package.js:
--------------------------------------------------------------------------------
1 | Package.describe({
2 | name: 'orionsoft:react-meteor-data',
3 | version: '0.1.5',
4 | summary: 'Fetch Meteor data in React using decorators',
5 | git: 'https://github.com/orionsoft/react-meteor-data',
6 | documentation: 'README.md'
7 | })
8 |
9 | Package.onUse(function (api) {
10 | api.versionsFrom('1.4.1.1')
11 | api.use('ecmascript')
12 | api.use('underscore')
13 | api.use('react-meteor-data@0.2.9')
14 | api.mainModule('main.js')
15 | })
16 |
17 | Package.onTest(function (api) {
18 | api.use('ecmascript')
19 | api.use('tinytest')
20 | api.use('orionsoft:react-meteor-data')
21 | // api.mainModule('react-meteor-data-tests.js')
22 | })
23 |
--------------------------------------------------------------------------------
/with-method-data.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import {_} from 'meteor/underscore'
3 |
4 | export default function (getData) {
5 | return function (ComposedComponent) {
6 | return class Component extends React.Component {
7 |
8 | constructor (props) {
9 | super(props)
10 | this.state = {
11 | isLoading: true
12 | }
13 | }
14 |
15 | componentWillReceiveProps (nextProps) {
16 | if (!_.isEqual(this.props, nextProps)) {
17 | this.fetchData(nextProps)
18 | }
19 | }
20 |
21 | componentWillMount () {
22 | this.fetchData(this.props)
23 | }
24 |
25 | fetchData (props) {
26 | this.setState({isLoading: true})
27 | getData(props, (error, response) => {
28 | this.setState({isLoading: false, response, error})
29 | })
30 | }
31 |
32 | render () {
33 | return