react-xstream-store
Advanced tools
Comparing version
@@ -34,3 +34,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.xstreamStore = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
streamState: {}, | ||
dispatch: function () { } | ||
dispatch: function () { }, | ||
}; | ||
@@ -44,3 +44,3 @@ var _a = React.createContext(defaultContextValue), OriginalProvider = _a.Provider, OriginalConsumer = _a.Consumer; | ||
var action = actions[actionName]; | ||
var isActionCreator = typeof action === "function"; | ||
var isActionCreator = typeof action === 'function'; | ||
var actionToReturn = isActionCreator | ||
@@ -76,3 +76,3 @@ ? function () { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.displayName = "XstreamProvider"; | ||
_this.displayName = 'XstreamProvider'; | ||
_this.subscription = { unsubscribe: function () { } }; | ||
@@ -91,3 +91,3 @@ return _this; | ||
}, | ||
complete: function () { } | ||
complete: function () { }, | ||
}); | ||
@@ -101,3 +101,3 @@ }; | ||
var streamState = this.state || store.initialState; | ||
return (React.createElement(OriginalProvider, { children: children, value: { streamState: streamState, dispatch: store.dispatch } })); | ||
return React.createElement(OriginalProvider, { children: children, value: { streamState: streamState, dispatch: store.dispatch } }); | ||
}; | ||
@@ -111,3 +111,3 @@ return Provider; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.displayName = "XstreamConsumer"; | ||
_this.displayName = 'XstreamConsumer'; | ||
return _this; | ||
@@ -124,3 +124,3 @@ } | ||
Consumer: Consumer, | ||
Provider: Provider | ||
Provider: Provider, | ||
}; | ||
@@ -136,8 +136,8 @@ var withStream = function (selector, actions) { return function (ComponentToWrap) { | ||
var _a = this.props, innerRef = _a.innerRef, restProps = __rest(_a, ["innerRef"]); | ||
return (React.createElement(Consumer, __assign({}, restProps, { actions: actions, children: function (consumerProps) { return (React.createElement(ComponentToWrap, __assign({}, consumerProps, restProps))); }, ref: innerRef, selector: selector }))); | ||
return (React.createElement(Consumer, __assign({}, restProps, { actions: actions, children: function (consumerProps) { return React.createElement(ComponentToWrap, __assign({}, consumerProps, restProps)); }, ref: innerRef, selector: selector }))); | ||
}; | ||
return class_1; | ||
}(React.Component)), | ||
_a.displayName = "withXstream(" + (ComponentToWrap | ||
.displayName || "Unknown") + ")", | ||
_a.displayName = "withXstream(" + (ComponentToWrap.displayName || | ||
'Unknown') + ")", | ||
_a; | ||
@@ -144,0 +144,0 @@ }; }; |
@@ -1,4 +0,4 @@ | ||
import * as React from "react"; | ||
import { Stream } from "xstream"; | ||
import { Action, Dispatch } from "xstream-store"; | ||
import * as React from 'react'; | ||
import { Stream } from 'xstream'; | ||
import { Action, Dispatch } from 'xstream-store'; | ||
export interface State { | ||
@@ -16,24 +16,23 @@ [key: string]: any; | ||
export interface StoreContext { | ||
dispatch: Dispatch; | ||
streamState: State; | ||
dispatch: Dispatch; | ||
} | ||
export declare type ActionBinder = (...xs: any[]) => void; | ||
export interface XstreamConnectConsumerProps { | ||
streamState: State; | ||
export interface XstreamConnectConsumerProps extends React.Props<any> { | ||
actions?: ActionMap; | ||
children: (a: any) => React.ReactNode; | ||
dispatch: Dispatch; | ||
actions?: ActionMap; | ||
selector?: StateSelector; | ||
children?: (a: any) => React.ReactNode; | ||
streamState: State; | ||
} | ||
export interface ConsumerProps { | ||
export interface ConsumerProps extends React.ConsumerProps<any> { | ||
actions?: ActionMap; | ||
children: (...props: any[]) => React.ReactNode; | ||
selector?: StateSelector; | ||
ref?: React.RefObject<any>; | ||
} | ||
export interface XstreamProviderProps { | ||
store: { | ||
state$: State$; | ||
dispatch: Dispatch; | ||
initialState: State; | ||
state$: State$; | ||
}; | ||
@@ -58,5 +57,5 @@ } | ||
}; | ||
export declare type WithStream = (selector?: StateSelector | null, actions?: ActionMap | null) => React.ReactNode; | ||
export declare type WithStream = (selector?: StateSelector | null, actions?: ActionMap | null) => any; | ||
declare const withStream: WithStream; | ||
export { Provider, Consumer, withStream }; | ||
export default XstreamContext; |
20
index.js
@@ -33,3 +33,3 @@ "use strict"; | ||
streamState: {}, | ||
dispatch: function () { } | ||
dispatch: function () { }, | ||
}; | ||
@@ -43,3 +43,3 @@ var _a = React.createContext(defaultContextValue), OriginalProvider = _a.Provider, OriginalConsumer = _a.Consumer; | ||
var action = actions[actionName]; | ||
var isActionCreator = typeof action === "function"; | ||
var isActionCreator = typeof action === 'function'; | ||
var actionToReturn = isActionCreator | ||
@@ -75,3 +75,3 @@ ? function () { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.displayName = "XstreamProvider"; | ||
_this.displayName = 'XstreamProvider'; | ||
_this.subscription = { unsubscribe: function () { } }; | ||
@@ -90,3 +90,3 @@ return _this; | ||
}, | ||
complete: function () { } | ||
complete: function () { }, | ||
}); | ||
@@ -100,3 +100,3 @@ }; | ||
var streamState = this.state || store.initialState; | ||
return (React.createElement(OriginalProvider, { children: children, value: { streamState: streamState, dispatch: store.dispatch } })); | ||
return React.createElement(OriginalProvider, { children: children, value: { streamState: streamState, dispatch: store.dispatch } }); | ||
}; | ||
@@ -110,3 +110,3 @@ return Provider; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.displayName = "XstreamConsumer"; | ||
_this.displayName = 'XstreamConsumer'; | ||
return _this; | ||
@@ -123,3 +123,3 @@ } | ||
Consumer: Consumer, | ||
Provider: Provider | ||
Provider: Provider, | ||
}; | ||
@@ -135,8 +135,8 @@ var withStream = function (selector, actions) { return function (ComponentToWrap) { | ||
var _a = this.props, innerRef = _a.innerRef, restProps = __rest(_a, ["innerRef"]); | ||
return (React.createElement(Consumer, __assign({}, restProps, { actions: actions, children: function (consumerProps) { return (React.createElement(ComponentToWrap, __assign({}, consumerProps, restProps))); }, ref: innerRef, selector: selector }))); | ||
return (React.createElement(Consumer, __assign({}, restProps, { actions: actions, children: function (consumerProps) { return React.createElement(ComponentToWrap, __assign({}, consumerProps, restProps)); }, ref: innerRef, selector: selector }))); | ||
}; | ||
return class_1; | ||
}(React.Component)), | ||
_a.displayName = "withXstream(" + (ComponentToWrap | ||
.displayName || "Unknown") + ")", | ||
_a.displayName = "withXstream(" + (ComponentToWrap.displayName || | ||
'Unknown') + ")", | ||
_a; | ||
@@ -143,0 +143,0 @@ }; }; |
{ | ||
"name": "react-xstream-store", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "A ReactJS state provider and connector for xstream-store", | ||
@@ -39,4 +39,4 @@ "main": "index.js", | ||
"@types/jest": "^22.2.3", | ||
"@types/react": "^16.3.16", | ||
"@types/react-dom": "^16.0.6", | ||
"@types/react": "16.4.11", | ||
"@types/react-dom": "16.0.7", | ||
"babel-core": "6.26.3", | ||
@@ -43,0 +43,0 @@ "babel-preset-env": "^1.7.0", |
Sorry, the diff of this file is not supported yet
31429
-0.08%339
-0.29%