1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.areObservable = areObservable;
|
7 | exports.createObjectValidator = createObjectValidator;
|
8 | exports.getName = getName;
|
9 | exports.getNameOrNull = getNameOrNull;
|
10 | exports.isObservable = isObservable;
|
11 | exports.isPromise = isPromise;
|
12 | exports.isKitten = isKitten;
|
13 | exports.isStore = isStore;
|
14 |
|
15 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
16 |
|
17 | var _rx = require('rx');
|
18 |
|
19 | var _invariant = require('invariant');
|
20 |
|
21 | var _invariant2 = _interopRequireDefault(_invariant);
|
22 |
|
23 | var isFunction = _rx.helpers.isFunction;
|
24 | exports.isFunction = isFunction;
|
25 | var __DEV__ = process.env.NODE_ENV !== 'production';
|
26 |
|
27 | exports.__DEV__ = __DEV__;
|
28 |
|
29 | function areObservable(observables) {
|
30 | return Array.isArray(observables) && observables.length > 0 && observables.reduce(function (bool, observable) {
|
31 | return bool && isObservable(observable);
|
32 | }, true);
|
33 | }
|
34 |
|
35 | function createObjectValidator(message) {
|
36 | return function (obj) {
|
37 |
|
38 | if (__DEV__) {
|
39 | (0, _invariant2['default'])(obj && typeof obj === 'object', message, obj);
|
40 | }
|
41 | };
|
42 | }
|
43 |
|
44 | function getName(comp) {
|
45 | return '' + (getNameOrNull(comp) || 'Anonymous');
|
46 | }
|
47 |
|
48 | function getNameOrNull(comp) {
|
49 | return !!comp && (comp && comp.displayName || comp.constructor && comp.constructor.displayName || comp.fixed && comp.fixed.refs && comp.fixed.refs.displayName) || null;
|
50 | }
|
51 |
|
52 | function isObservable(observable) {
|
53 | return observable && typeof observable.subscribe === 'function';
|
54 | }
|
55 |
|
56 | function isPromise(promise) {
|
57 | return promise && typeof promise.then === 'function';
|
58 | }
|
59 |
|
60 | function isKitten(obj) {
|
61 | return !!(obj && isFunction(obj.register) && isFunction(obj.getStore) && isFunction(obj.getActions));
|
62 | }
|
63 |
|
64 | function isStore(obj) {
|
65 | return !!(obj && isFunction(obj.createRegistrar) && isFunction(obj.fromMany) && isFunction(obj.replacer) && isFunction(obj.setter) && isFunction(obj.transformer));
|
66 | } |
\ | No newline at end of file |