cortina-react
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "cortina-react", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Coroutine-based EDSL for building React components and applications", | ||
@@ -5,0 +5,0 @@ "author": "Arthur Xavier <arthur.xavierx@gmail.com> (http://arthur-xavier.github.io/)", |
import React, { Component } from 'react'; | ||
import { Process } from 'cora'; | ||
import { all, race } from 'cora/src/combinators'; | ||
import { getIterator, isFunction } from 'cora/src/types'; | ||
@@ -52,3 +53,3 @@ | ||
this.cancel(); | ||
if (this.mounted) this.forceUpdate(this.props); | ||
if (this.mounted) this.forceUpdate(this.props, prevProps); | ||
} | ||
@@ -66,6 +67,7 @@ | ||
restart(props) { | ||
restart(props, prevProps) { | ||
this.iterator = getIterator( | ||
props.__iterator || this[Symbol.iterator], | ||
props | ||
props, | ||
prevProps | ||
); | ||
@@ -82,4 +84,4 @@ this.target = this.iterator; | ||
forceUpdate(props) { | ||
this.restart(props); | ||
forceUpdate(props, prevProps) { | ||
this.restart(props, prevProps); | ||
@@ -114,2 +116,5 @@ this.promise && this.promise.cancel(); | ||
return query; | ||
} else if (query instanceof all || query instanceof race) { | ||
query.handler = this._handler; | ||
return query; | ||
} else { | ||
@@ -116,0 +121,0 @@ return query; |
@@ -21,9 +21,19 @@ import { Channel, Query } from 'cora'; | ||
this.channel = new Channel(); | ||
this.send = value => this.channel.put(value); | ||
this.dispatch = value => this.channel.put(value); | ||
this.take = this.channel.take; | ||
return function*() { | ||
yield this.view(this.send); | ||
yield this.view(this.dispatch); | ||
return this.take; | ||
}; | ||
}); | ||
export function mapDispatch(actions, dispatch) { | ||
return Object.keys(actions).reduce( | ||
(obj, key) => ({ | ||
...obj, | ||
[key]: (...args) => dispatch(actions[key](...args)), | ||
}), | ||
{} | ||
); | ||
} |
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
16625
132