Comparing version 1.1.4 to 1.1.5
@@ -34,3 +34,3 @@ 'use strict'; | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
this.doUnsubscribe(); | ||
this.componentWillUnmount(); | ||
this.doSubscribe(nextProps); | ||
@@ -40,5 +40,2 @@ }, | ||
this.doSubscribe(this.props); | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.doUnsubscribe(); | ||
} | ||
@@ -51,6 +48,5 @@ }); | ||
LiftedComponent.call(this, props); | ||
this.callback = null; | ||
this.rendered = null; | ||
this.callback = this.rendered = null; | ||
}, LiftedComponent, { | ||
doUnsubscribe: function doUnsubscribe() { | ||
componentWillUnmount: function componentWillUnmount() { | ||
var callback = this.callback; | ||
@@ -197,3 +193,29 @@ if (callback) this.props.observable.offAny(callback); | ||
var handler = function handler(e) { | ||
return self.doHandleN(handler, e); | ||
var handlers = self.handlers; | ||
var idx = 0; | ||
while (handlers[idx] !== handler) { | ||
++idx; | ||
}switch (e.type) { | ||
case VALUE: | ||
{ | ||
var value = e.value; | ||
var values = self.values; | ||
if (values[idx] !== value) { | ||
values[idx] = value; | ||
self.forceUpdate(); | ||
} | ||
break; | ||
} | ||
case ERROR: | ||
throw e.value; | ||
default: | ||
{ | ||
handlers[idx] = null; | ||
var n = handlers.length; | ||
if (n !== self.values.length) return; | ||
for (var i = 0; i < n; ++i) { | ||
if (handlers[i]) return; | ||
}self.handlers = null; | ||
} | ||
} | ||
}; | ||
@@ -209,3 +231,3 @@ self.handlers.push(handler); | ||
}, LiftedComponent, { | ||
doUnsubscribe: function doUnsubscribe() { | ||
componentWillUnmount: function componentWillUnmount() { | ||
var handlers = this.handlers; | ||
@@ -233,3 +255,20 @@ if (handlers instanceof Function) { | ||
var handlers = function handlers(e) { | ||
return _this2.doHandle1(e); | ||
switch (e.type) { | ||
case VALUE: | ||
{ | ||
var value = e.value; | ||
if (_this2.values !== value) { | ||
_this2.values = value; | ||
_this2.forceUpdate(); | ||
} | ||
break; | ||
} | ||
case ERROR: | ||
throw e.value; | ||
default: | ||
{ | ||
_this2.values = [_this2.values]; | ||
_this2.handlers = null; | ||
} | ||
} | ||
}; | ||
@@ -246,51 +285,2 @@ this.handlers = handlers; | ||
}, | ||
doHandle1: function doHandle1(e) { | ||
switch (e.type) { | ||
case VALUE: | ||
{ | ||
var value = e.value; | ||
if (this.values !== value) { | ||
this.values = value; | ||
this.forceUpdate(); | ||
} | ||
break; | ||
} | ||
case ERROR: | ||
throw e.value; | ||
default: | ||
{ | ||
this.values = [this.values]; | ||
this.handlers = null; | ||
} | ||
} | ||
}, | ||
doHandleN: function doHandleN(handler, e) { | ||
var handlers = this.handlers; | ||
var idx = 0; | ||
while (handlers[idx] !== handler) { | ||
++idx; | ||
}switch (e.type) { | ||
case VALUE: | ||
{ | ||
var value = e.value; | ||
var values = this.values; | ||
if (values[idx] !== value) { | ||
values[idx] = value; | ||
this.forceUpdate(); | ||
} | ||
break; | ||
} | ||
case ERROR: | ||
throw e.value; | ||
default: | ||
{ | ||
handlers[idx] = null; | ||
var n = handlers.length; | ||
if (n !== this.values.length) return; | ||
for (var i = 0; i < n; ++i) { | ||
if (handlers[i]) return; | ||
}this.handlers = null; | ||
} | ||
} | ||
}, | ||
render: function render() { | ||
@@ -297,0 +287,0 @@ if (this.handlers instanceof Function) { |
@@ -31,3 +31,3 @@ import { Component, PropTypes, createElement } from 'react'; | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
this.doUnsubscribe(); | ||
this.componentWillUnmount(); | ||
this.doSubscribe(nextProps); | ||
@@ -37,5 +37,2 @@ }, | ||
this.doSubscribe(this.props); | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.doUnsubscribe(); | ||
} | ||
@@ -48,6 +45,5 @@ }); | ||
LiftedComponent.call(this, props); | ||
this.callback = null; | ||
this.rendered = null; | ||
this.callback = this.rendered = null; | ||
}, LiftedComponent, { | ||
doUnsubscribe: function doUnsubscribe() { | ||
componentWillUnmount: function componentWillUnmount() { | ||
var callback = this.callback; | ||
@@ -194,3 +190,29 @@ if (callback) this.props.observable.offAny(callback); | ||
var handler = function handler(e) { | ||
return self.doHandleN(handler, e); | ||
var handlers = self.handlers; | ||
var idx = 0; | ||
while (handlers[idx] !== handler) { | ||
++idx; | ||
}switch (e.type) { | ||
case VALUE: | ||
{ | ||
var value = e.value; | ||
var values = self.values; | ||
if (values[idx] !== value) { | ||
values[idx] = value; | ||
self.forceUpdate(); | ||
} | ||
break; | ||
} | ||
case ERROR: | ||
throw e.value; | ||
default: | ||
{ | ||
handlers[idx] = null; | ||
var n = handlers.length; | ||
if (n !== self.values.length) return; | ||
for (var i = 0; i < n; ++i) { | ||
if (handlers[i]) return; | ||
}self.handlers = null; | ||
} | ||
} | ||
}; | ||
@@ -206,3 +228,3 @@ self.handlers.push(handler); | ||
}, LiftedComponent, { | ||
doUnsubscribe: function doUnsubscribe() { | ||
componentWillUnmount: function componentWillUnmount() { | ||
var handlers = this.handlers; | ||
@@ -230,3 +252,20 @@ if (handlers instanceof Function) { | ||
var handlers = function handlers(e) { | ||
return _this2.doHandle1(e); | ||
switch (e.type) { | ||
case VALUE: | ||
{ | ||
var value = e.value; | ||
if (_this2.values !== value) { | ||
_this2.values = value; | ||
_this2.forceUpdate(); | ||
} | ||
break; | ||
} | ||
case ERROR: | ||
throw e.value; | ||
default: | ||
{ | ||
_this2.values = [_this2.values]; | ||
_this2.handlers = null; | ||
} | ||
} | ||
}; | ||
@@ -243,51 +282,2 @@ this.handlers = handlers; | ||
}, | ||
doHandle1: function doHandle1(e) { | ||
switch (e.type) { | ||
case VALUE: | ||
{ | ||
var value = e.value; | ||
if (this.values !== value) { | ||
this.values = value; | ||
this.forceUpdate(); | ||
} | ||
break; | ||
} | ||
case ERROR: | ||
throw e.value; | ||
default: | ||
{ | ||
this.values = [this.values]; | ||
this.handlers = null; | ||
} | ||
} | ||
}, | ||
doHandleN: function doHandleN(handler, e) { | ||
var handlers = this.handlers; | ||
var idx = 0; | ||
while (handlers[idx] !== handler) { | ||
++idx; | ||
}switch (e.type) { | ||
case VALUE: | ||
{ | ||
var value = e.value; | ||
var values = this.values; | ||
if (values[idx] !== value) { | ||
values[idx] = value; | ||
this.forceUpdate(); | ||
} | ||
break; | ||
} | ||
case ERROR: | ||
throw e.value; | ||
default: | ||
{ | ||
handlers[idx] = null; | ||
var n = handlers.length; | ||
if (n !== this.values.length) return; | ||
for (var i = 0; i < n; ++i) { | ||
if (handlers[i]) return; | ||
}this.handlers = null; | ||
} | ||
} | ||
}, | ||
render: function render() { | ||
@@ -294,0 +284,0 @@ if (this.handlers instanceof Function) { |
{ | ||
"name": "karet", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Karet is a library that allows you to embed Kefir observables into React VDOM", | ||
"module": "dist/karet.es.js", | ||
"main": "dist/karet.cjs.js", | ||
"module": "dist/karet.es.js", | ||
"scripts": { | ||
"dist": "npm run dist:es & npm run dist:cjs & wait", | ||
"dist": "npm run dist:umd & npm run dist:umd.min & npm run dist:es & npm run dist:cjs & wait", | ||
"dist:cjs": " NODE_ENV= rollup -c -n karet -i src/karet.js -f cjs -o dist/karet.cjs.js", | ||
"dist:es": " NODE_ENV= rollup -c -n karet -i src/karet.js -f es -o dist/karet.es.js", | ||
"dist:umd": " NODE_ENV=dev rollup -c -n karet -i src/karet.js -f umd -o dist/karet.js", | ||
"dist:umd.min": "NODE_ENV=production rollup -c -n karet -i src/karet.js -f umd -o dist/karet.min.js", | ||
"lint": "eslint src test", | ||
@@ -12,0 +14,0 @@ "prepublish": "npm run lint && npm run dist && npm run test", |
103
src/karet.js
@@ -36,3 +36,3 @@ import * as React from "react" | ||
componentWillReceiveProps(nextProps) { | ||
this.doUnsubscribe() | ||
this.componentWillUnmount() | ||
this.doSubscribe(nextProps) | ||
@@ -42,5 +42,2 @@ }, | ||
this.doSubscribe(this.props) | ||
}, | ||
componentWillUnmount() { | ||
this.doUnsubscribe() | ||
} | ||
@@ -53,6 +50,6 @@ }) | ||
LiftedComponent.call(this, props) | ||
this.callback = null | ||
this.callback = | ||
this.rendered = null | ||
}, LiftedComponent, { | ||
doUnsubscribe() { | ||
componentWillUnmount() { | ||
const callback = this.callback | ||
@@ -196,3 +193,30 @@ if (callback) | ||
function onAny(self, obs) { | ||
const handler = e => self.doHandleN(handler, e) | ||
const handler = e => { | ||
const handlers = self.handlers | ||
let idx=0 | ||
while (handlers[idx] !== handler) | ||
++idx | ||
switch (e.type) { | ||
case VALUE: { | ||
const value = e.value | ||
const values = self.values | ||
if (values[idx] !== value) { | ||
values[idx] = value | ||
self.forceUpdate() | ||
} | ||
break | ||
} | ||
case ERROR: throw e.value | ||
default: { | ||
handlers[idx] = null | ||
const n = handlers.length | ||
if (n !== self.values.length) | ||
return | ||
for (let i=0; i < n; ++i) | ||
if (handlers[i]) | ||
return | ||
self.handlers = null | ||
} | ||
} | ||
} | ||
self.handlers.push(handler) | ||
@@ -207,3 +231,3 @@ obs.onAny(handler) | ||
}, LiftedComponent, { | ||
doUnsubscribe() { | ||
componentWillUnmount() { | ||
const handlers = this.handlers | ||
@@ -227,3 +251,19 @@ if (handlers instanceof Function) { | ||
this.values = this | ||
const handlers = e => this.doHandle1(e) | ||
const handlers = e => { | ||
switch (e.type) { | ||
case VALUE: { | ||
const value = e.value | ||
if (this.values !== value) { | ||
this.values = value | ||
this.forceUpdate() | ||
} | ||
break | ||
} | ||
case ERROR: throw e.value | ||
default: { | ||
this.values = [this.values] | ||
this.handlers = null | ||
} | ||
} | ||
} | ||
this.handlers = handlers | ||
@@ -239,47 +279,2 @@ forEach(props, handlers, onAny1) | ||
}, | ||
doHandle1(e) { | ||
switch (e.type) { | ||
case VALUE: { | ||
const value = e.value | ||
if (this.values !== value) { | ||
this.values = value | ||
this.forceUpdate() | ||
} | ||
break | ||
} | ||
case ERROR: throw e.value | ||
default: { | ||
this.values = [this.values] | ||
this.handlers = null | ||
} | ||
} | ||
}, | ||
doHandleN(handler, e) { | ||
const handlers = this.handlers | ||
let idx=0 | ||
while (handlers[idx] !== handler) | ||
++idx | ||
switch (e.type) { | ||
case VALUE: { | ||
const value = e.value | ||
const values = this.values | ||
if (values[idx] !== value) { | ||
values[idx] = value | ||
this.forceUpdate() | ||
} | ||
break | ||
} | ||
case ERROR: throw e.value | ||
default: { | ||
handlers[idx] = null | ||
const n = handlers.length | ||
if (n !== this.values.length) | ||
return | ||
for (let i=0; i < n; ++i) | ||
if (handlers[i]) | ||
return | ||
this.handlers = null | ||
} | ||
} | ||
}, | ||
render() { | ||
@@ -286,0 +281,0 @@ if (this.handlers instanceof Function) { |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
91634
12
1393
1