all files / src/ Provider.js

92.86% Statements 26/28
66.67% Branches 6/9
100% Functions 6/6
100% Lines 25/25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                                             
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var react_1 = require('react');
var Provider = (function (_super) {
    __extends(Provider, _super);
    function Provider(props, context) {
        _super.call(this, props, context);
        this.client = props.client;
        if (props.store) {
            this.store = props.store;
            return;
        }
        props.client.initStore();
        this.store = props.client.store;
    }
    Provider.prototype.getChildContext = function () {
        return {
            store: this.store,
            client: this.client,
        };
    };
    Provider.prototype.render = function () {
        var children = this.props.children;
        return react_1.Children.only(children);
    };
    Provider.propTypes = {
        store: react_1.PropTypes.shape({
            subscribe: react_1.PropTypes.func.isRequired,
            dispatch: react_1.PropTypes.func.isRequired,
            getState: react_1.PropTypes.func.isRequired,
        }),
        client: react_1.PropTypes.object.isRequired,
        children: react_1.PropTypes.element.isRequired,
    };
    Provider.childContextTypes = {
        store: react_1.PropTypes.object.isRequired,
        client: react_1.PropTypes.object.isRequired,
    };
    return Provider;
}(react_1.Component));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Provider;
;
//# sourceMappingURL=Provider.js.map