Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rewrite connect() for better performance and extensibility#416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
jimbolla wants to merge76 commits intoreduxjs:masterfromjimbolla:connect-rewrite
Closed
Changes from1 commit
Commits
Show all changes
76 commits
Select commitHold shift + click to select a range
ee4366b
Reimplementing connect() and extracting connectToStore() based on 're…
jimbollaJun 16, 2016
2aec436
Changes to fix failing tests (4 fails to go)
jimbollaJun 16, 2016
fe7358c
Change code to make tests for factory mapStateToProps/mapDispatchToPr…
jimbollaJun 16, 2016
9967a18
Adjust remaining 2 failing tests to account for slightly different be…
jimbollaJun 16, 2016
a12c1ec
add dispatchable to the exported functions
jimbollaJun 16, 2016
27f613d
Replace string ref with function ref. Adjust test to match
jimbollaJun 16, 2016
106ded6
Generalized a couple error messages
jimbollaJun 16, 2016
cde8ba2
make additional options passed to connect() fall through to connectTo…
jimbollaJun 16, 2016
5a631ab
rename connectToStore to connectAdvanced
jimbollaJun 16, 2016
3416b42
pull some utility functions out of connectAdvanced into their own uti…
jimbollaJun 16, 2016
6786824
refactor connect + connectAdvanced
jimbollaJun 16, 2016
5e72f23
remove dispatchable()... this probably doesn't need to be a part of r…
jimbollaJun 16, 2016
7890b4c
remove unneeded selector value on unmount
jimbollaJun 16, 2016
612562d
avoid excess verify() when using defaultMergeProps
jimbollaJun 17, 2016
81434df
pull buildSelector out of connectAdvanced... less function nesting
jimbollaJun 17, 2016
71655ad
refactor connect() selector builders
jimbollaJun 17, 2016
3266aa9
remove need for explicit factory flags
jimbollaJun 17, 2016
4dbeeb1
don't do shape verification in production ENV
jimbollaJun 17, 2016
74e0e09
refactor to split init from trySubscribe
jimbollaJun 17, 2016
cd75a22
Move subscribe from willMount to didMount to avoid serverside memory …
jimbollaJun 17, 2016
9de43b2
Remove extra createShallowEqualSelector file since it's not adding mu…
jimbollaJun 17, 2016
3e1ddbd
move ref/recomputationsProp setters into buildSelector... simplify re…
jimbollaJun 17, 2016
b769209
refactor + comment advancedConnect
jimbollaJun 17, 2016
70395c9
pull buildSelector func into own file
jimbollaJun 17, 2016
2ae0c3c
Make buildSelector injectable into connectAdvanced as another option
jimbollaJun 17, 2016
e2e7108
refactor+comment connect.js
jimbollaJun 18, 2016
88e768b
Change the way nested connected components subscribe so that parent c…
jimbollaJun 18, 2016
d2b9844
Fix failing tests. Change the way nested components subscribe... inst…
jimbollaJun 18, 2016
859d795
ensure nested subs are notified properly
jimbollaJun 18, 2016
ce49933
Eliminate extraneous tracking of recomputations count since we can ju…
jimbollaJun 18, 2016
c72bcc0
simplify nested subs code. no need for extra object wrappers
jimbollaJun 18, 2016
9fef522
rename shouldUseState to dependsOnState to make its meaning more clear
jimbollaJun 18, 2016
ed52f05
prebind notifyNestedSubs to avoid extra lambda func
jimbollaJun 18, 2016
39fbe00
Add WrappedComponent as one of the option params passed to buildSelec…
jimbollaJun 18, 2016
1b8fb69
Extract Subscription class from connectAdvanced
jimbollaJun 19, 2016
5f0f85f
Replace reselect with manual memoization in buildSelector. Faster!
jimbollaJun 19, 2016
03c62ef
refactor buildSelector
jimbollaJun 19, 2016
0906904
refactor connect()... extract selectors, replace reselect with hand-r…
jimbollaJun 20, 2016
d4686d8
Re-add isSubscribed() to reduce test delta
jimbollaJun 20, 2016
a45ae23
refactor buildFactoryAwareSelector and remove extraneous selector ind…
jimbollaJun 20, 2016
e51315f
improve memoization perf
jimbollaJun 20, 2016
4969368
refactor connect + selectors for clarity
jimbollaJun 21, 2016
b1cc3d3
refactor connect + selectors
jimbollaJun 23, 2016
78045dc
pull apart buildSelector into its pieces and move them into getFinalP…
jimbollaJun 23, 2016
846c09b
Move where 'extra props' (ref and recomputations) are added to the fi…
jimbollaJun 23, 2016
ee77f3f
Refactor props memoization
jimbollaJun 23, 2016
8170f16
Move ownProps memoization into connectAdvanced to simplify selectors.
jimbollaJun 23, 2016
3287546
utilize memoizeProps in createFactoryAwareSelector
jimbollaJun 23, 2016
0b9fd95
rename recomputations to renderCount to make its intent clearer
jimbollaJun 24, 2016
30857f4
refactoring selectors + connect for clarity
jimbollaJun 24, 2016
1e0a66c
Hide connectAdvanced and advancedOptions
jimbollaJun 24, 2016
5bc7b83
fix nits
jimbollaJun 26, 2016
1e7f2d7
fix messed up path
jimbollaJun 26, 2016
e284d8b
Add guard for the case of a component causing its siblings to unsubsc…
jimbollaJul 2, 2016
395c4ee
Add comments to connect.js
jimbollaJul 3, 2016
dab9c85
refactoring + some perf opimizations
jimbollaJul 9, 2016
cabd376
refactoring+comments for clarity
jimbollaJul 9, 2016
35d175f
refactoring
jimbollaJul 9, 2016
67d6e13
Optimize Subscription subscribe/unsubscribe
jimbollaJul 9, 2016
a604856
comments
jimbollaJul 9, 2016
652d85c
refactor selectors
jimbollaJul 10, 2016
d56c36d
rename files
jimbollaJul 10, 2016
418b659
Change Subscription to follow same subscribe/unsubscribe/notify mecha…
jimbollaJul 11, 2016
44fd92d
refactoring connect's selectors to move logic to determine what to re…
jimbollaJul 11, 2016
1cb72c0
refactoring/optimizing connect+selectors
jimbollaJul 12, 2016
5ec8143
refactoring/optimizing connect+selectors
jimbollaJul 13, 2016
1120555
Merge selectors and connect.js into a connect folder
jimbollaJul 14, 2016
55b49b2
comments
jimbollaJul 14, 2016
86a4bbe
refactoring connect
jimbollaJul 15, 2016
3cc504f
Optimize connectAdvanced to not create subscription if it shouldn't r…
jimbollaJul 16, 2016
3c5c80e
Refactor - put dependsOnOwnProps right on the selector func instead o…
jimbollaJul 16, 2016
de81801
Add test from #293 and uncomment now-passing expect in 'should pass s…
jimbollaJul 16, 2016
e2df051
Added passing test from #395
jimbollaJul 16, 2016
e907f85
Add passing test from #429
jimbollaJul 16, 2016
a6d82f0
Add code + test for #436
jimbollaJul 16, 2016
a4d3211
Extract buildConnectOptions out of connect()... will make testing easier
jimbollaJul 16, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
refactor to split init from trySubscribe
  • Loading branch information
@jimbolla
jimbolla committedJun 17, 2016
commit74e0e09b797a4429b5acb1d301c10b12cffbfe79
18 changes: 13 additions & 5 deletionssrc/components/connectAdvanced.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,10 +69,8 @@ export default function connectAdvanced(
constructor(props, context) {
super(props, context)
this.state = { storeUpdates: 0 }
}

componentWillMount() {
this.store = this.props[storeKey] || this.context[storeKey]

invariant(this.store,
`Could not find "${storeKey}" in either the context or ` +
`props of "${Connect.displayName}". ` +
Expand All@@ -83,6 +81,11 @@ export default function connectAdvanced(
this.init()
}

componentWillMount() {
// TODO this is bad. needs to be didMount, but fails a test.
this.trySubscribe()
}

shouldComponentUpdate(nextProps) {
return !pure || this.selector(nextProps).shouldUpdate
}
Expand All@@ -96,14 +99,16 @@ export default function connectAdvanced(

init() {
this.version = version

this.selector = buildSelector({
displayName: Connect.displayName,
store: this.store,
selectorFactory,
shouldUseState
})
}

trySubscribe() {
if (shouldUseState) {
if (this.unsubscribe) this.unsubscribe()

Expand DownExpand Up@@ -150,7 +155,10 @@ export default function connectAdvanced(
if (process.env.NODE_ENV !== 'production') {
Connect.prototype.componentWillUpdate = function componentWillUpdate() {
// We are hot reloading!
if (this.version !== version) this.init()
if (this.version !== version) {
this.init()
this.trySubscribe()
}
}
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp