Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Jan 23, 2018
1 parent c1dabf9 commit ef205a8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 114 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The connector for React 🌈 iFlow state management.
* Least possible time selector
* Automatic array diff
* Full support comprehensive selector
* Support immutable

### Install
```bash
Expand Down
10 changes: 5 additions & 5 deletions lib/predictable.js → lib/immutable.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import React, { Component, createElement } from 'react'
import hoistStatics from 'hoist-non-react-statics'
import { predict } from 'iflow'
import { getImmutable } from 'iflow'
import { isStatelessComponent } from '../utils/tools'

export default function predictable (TargetComponent) {
export default function immutable (TargetComponent) {
class PredictableComponent extends Component {
static WrappedComponent = TargetComponent
static displayName = TargetComponent.displayName
_isStatelessComponent = isStatelessComponent(TargetComponent)

render () {
const predictableProps = Object.entries(this.props).reduce((props, [key, value]) => {
const immutableProps = Object.entries(this.props).reduce((props, [key, value]) => {
if (value !== null && typeof value === 'object' && value['__pipe__']) {
props[key] = predict(value)
props[key] = getImmutable(value)
}
return props
}, {})
return createElement(TargetComponent, {
...this.props,
...predictableProps,
...immutableProps,
...this._isStatelessComponent ? {} : {ref: (ref) => this.wrappedInstance = ref}
})
}
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import flow from './flow'
import Provider from './provider'
import predictable from './predictable'
import immutable from './immutable'

const connect = flow()

Expand All @@ -9,5 +9,5 @@ export {
flow,
connect,
Provider,
predictable
immutable
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-iflow",
"version": "1.0.0-alpha.25",
"version": "1.0.0-alpha.26",
"description": "The connector for react and iFlow state management.",
"main": "dist/cjs/index.js",
"module": "dist/es/index.js",
Expand Down Expand Up @@ -62,7 +62,7 @@
},
"dependencies": {
"hoist-non-react-statics": "^2.3.1",
"iflow": "^1.0.0-alpha.35",
"iflow": "^1.0.0-alpha.38",
"prop-types": "^15.6.0",
"react": "^16.2.0"
}
Expand Down
108 changes: 3 additions & 105 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1067,27 +1067,6 @@ chalk@^2.0.0, chalk@^2.0.1:
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"

cheerio@*:
version "0.22.0"
resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e"
dependencies:
css-select "~1.2.0"
dom-serializer "~0.1.0"
entities "~1.1.1"
htmlparser2 "^3.9.1"
lodash.assignin "^4.0.9"
lodash.bind "^4.1.4"
lodash.defaults "^4.0.1"
lodash.filter "^4.4.0"
lodash.flatten "^4.2.0"
lodash.foreach "^4.3.0"
lodash.map "^4.4.0"
lodash.merge "^4.4.0"
lodash.pick "^4.2.1"
lodash.reduce "^4.4.0"
lodash.reject "^4.4.0"
lodash.some "^4.4.0"

cheerio@^1.0.0-rc.2:
version "1.0.0-rc.2"
resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.2.tgz#4b9f53a81b27e4d5dac31c0ffd0cfa03cc6830db"
Expand Down Expand Up @@ -1728,33 +1707,6 @@ getpass@^0.1.1:
dependencies:
assert-plus "^1.0.0"

gitbook-plugin-anchors@^0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/gitbook-plugin-anchors/-/gitbook-plugin-anchors-0.7.1.tgz#8f585b99ab1a602ea714342258c957238e36ec82"
dependencies:
cheerio "*"
github-slugid "1.0.1"

gitbook-plugin-copy-code-button@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/gitbook-plugin-copy-code-button/-/gitbook-plugin-copy-code-button-0.0.2.tgz#434533200b5cf596c284c14e1d8bb57772084475"

gitbook-plugin-edit-link@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/gitbook-plugin-edit-link/-/gitbook-plugin-edit-link-2.0.2.tgz#d8fcd927eced81e7a662a72d59db609eafd7e72f"

gitbook-plugin-github-buttons@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/gitbook-plugin-github-buttons/-/gitbook-plugin-github-buttons-3.0.0.tgz#0a57c9266514fe059b8084520d3b984424db6be1"

gitbook-plugin-github@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/gitbook-plugin-github/-/gitbook-plugin-github-2.0.0.tgz#5166e763cfcc402d432880b7a6c85c1c54b56a8d"

github-slugid@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/github-slugid/-/github-slugid-1.0.1.tgz#bccdd0815bfad69d8a359fa4fd65947d606ec3c0"

glob-base@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4"
Expand Down Expand Up @@ -1929,15 +1881,9 @@ iconv-lite@0.4.19, iconv-lite@~0.4.13:
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"

iflow@^1.0.0-alpha.35:
version "1.0.0-alpha.35"
resolved "https://registry.yarnpkg.com/iflow/-/iflow-1.0.0-alpha.35.tgz#08495ecf7245145d6a814bbd3d8d5d90cf6c2d6a"
dependencies:
gitbook-plugin-anchors "^0.7.1"
gitbook-plugin-copy-code-button "0.0.2"
gitbook-plugin-edit-link "^2.0.2"
gitbook-plugin-github "^2.0.0"
gitbook-plugin-github-buttons "^3.0.0"
iflow@^1.0.0-alpha.38:
version "1.0.0-alpha.38"
resolved "https://registry.yarnpkg.com/iflow/-/iflow-1.0.0-alpha.38.tgz#298055b903c691696efbfcb6f6e9b8b6188a5455"

imurmurhash@^0.1.4:
version "0.1.4"
Expand Down Expand Up @@ -2587,58 +2533,10 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

lodash.assignin@^4.0.9:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2"

lodash.bind@^4.1.4:
version "4.2.1"
resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35"

lodash.defaults@^4.0.1:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"

lodash.filter@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace"

lodash.flatten@^4.2.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"

lodash.flattendeep@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2"

lodash.foreach@^4.3.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53"

lodash.map@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"

lodash.merge@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5"

lodash.pick@^4.2.1:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3"

lodash.reduce@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b"

lodash.reject@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415"

lodash.some@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d"

lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
Expand Down

0 comments on commit ef205a8

Please sign in to comment.