refract-preact-xstream
Advanced tools
Comparing version 2.0.0-rc.1 to 2.0.0-rc.2
@@ -78,3 +78,5 @@ import xs from 'xstream'; | ||
}; | ||
var configureComponent = function (handler, errorHandler) { return function (aperture, instance, isValidElement) { | ||
var configureComponent = function (handler, errorHandler) { return function (aperture, instance, isValidElement, isComponentClass) { | ||
if (isValidElement === void 0) { isValidElement = function () { return false; }; } | ||
if (isComponentClass === void 0) { isComponentClass = function () { return false; }; } | ||
instance.state = { | ||
@@ -99,3 +101,3 @@ children: null, | ||
return function (effect) { | ||
if (isValidElement && isValidElement(effect)) { | ||
if (isValidElement(effect)) { | ||
setState({ | ||
@@ -113,4 +115,3 @@ children: effect | ||
var previousProp = instance.state.props[propName]; | ||
if (propName !== 'children' && | ||
typeof prop === 'function' && | ||
if (typeof prop === 'function' && | ||
prop !== previousProp) { | ||
@@ -143,3 +144,3 @@ decorateProp(props, prop, propName); | ||
var decorateProp = function (container, prop, propName) { | ||
if (propName === 'children') { | ||
if (propName === 'children' || isComponentClass(prop)) { | ||
return; | ||
@@ -220,4 +221,3 @@ } | ||
Object.keys(nextProps).forEach(function (propName) { | ||
if (propName !== 'children' && | ||
typeof instance.props[propName] === 'function' && | ||
if (typeof instance.props[propName] === 'function' && | ||
nextProps[propName] !== instance.props[propName]) { | ||
@@ -276,2 +276,7 @@ decorateProp(decoratedProps, nextProps[propName], propName); | ||
}; | ||
var isComponentClass = function (ComponentClass) { | ||
return Boolean(ComponentClass && | ||
ComponentClass.prototype && | ||
ComponentClass.prototype.componentDidMount); | ||
}; | ||
var withEffects = function (handler, errorHandler) { return function (aperture) { return function (BaseComponent) { | ||
@@ -285,3 +290,3 @@ if (BaseComponent === void 0) { BaseComponent = Empty; } | ||
_this.unmounted = false; | ||
configureComponent(handler, errorHandler)(aperture, _this, isValidElement); | ||
configureComponent(handler, errorHandler)(aperture, _this, isValidElement, isComponentClass); | ||
return _this; | ||
@@ -288,0 +293,0 @@ } |
21
index.js
@@ -84,3 +84,5 @@ 'use strict'; | ||
}; | ||
var configureComponent = function (handler, errorHandler) { return function (aperture, instance, isValidElement) { | ||
var configureComponent = function (handler, errorHandler) { return function (aperture, instance, isValidElement, isComponentClass) { | ||
if (isValidElement === void 0) { isValidElement = function () { return false; }; } | ||
if (isComponentClass === void 0) { isComponentClass = function () { return false; }; } | ||
instance.state = { | ||
@@ -105,3 +107,3 @@ children: null, | ||
return function (effect) { | ||
if (isValidElement && isValidElement(effect)) { | ||
if (isValidElement(effect)) { | ||
setState({ | ||
@@ -119,4 +121,3 @@ children: effect | ||
var previousProp = instance.state.props[propName]; | ||
if (propName !== 'children' && | ||
typeof prop === 'function' && | ||
if (typeof prop === 'function' && | ||
prop !== previousProp) { | ||
@@ -149,3 +150,3 @@ decorateProp(props, prop, propName); | ||
var decorateProp = function (container, prop, propName) { | ||
if (propName === 'children') { | ||
if (propName === 'children' || isComponentClass(prop)) { | ||
return; | ||
@@ -226,4 +227,3 @@ } | ||
Object.keys(nextProps).forEach(function (propName) { | ||
if (propName !== 'children' && | ||
typeof instance.props[propName] === 'function' && | ||
if (typeof instance.props[propName] === 'function' && | ||
nextProps[propName] !== instance.props[propName]) { | ||
@@ -282,2 +282,7 @@ decorateProp(decoratedProps, nextProps[propName], propName); | ||
}; | ||
var isComponentClass = function (ComponentClass) { | ||
return Boolean(ComponentClass && | ||
ComponentClass.prototype && | ||
ComponentClass.prototype.componentDidMount); | ||
}; | ||
var withEffects = function (handler, errorHandler) { return function (aperture) { return function (BaseComponent) { | ||
@@ -291,3 +296,3 @@ if (BaseComponent === void 0) { BaseComponent = Empty; } | ||
_this.unmounted = false; | ||
configureComponent(handler, errorHandler)(aperture, _this, isValidElement); | ||
configureComponent(handler, errorHandler)(aperture, _this, isValidElement, isComponentClass); | ||
return _this; | ||
@@ -294,0 +299,0 @@ } |
{ | ||
"name": "refract-preact-xstream", | ||
"description": "Refract bindings for Preact with xstream: master your app effects reactively!", | ||
"version": "2.0.0-rc.1", | ||
"version": "2.0.0-rc.2", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "jsnext:main": "index.es.js", |
@@ -9,4 +9,5 @@ import { Handler, ErrorHandler } from './baseTypes' | ||
instance: any, | ||
isValidElement?: (val: any) => boolean | ||
isValidElement?: (val: any) => boolean, | ||
isComponentClass?: (val: any) => boolean | ||
) => void | ||
export default configureComponent |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38363
789