This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove global observable and use Symbol.observable instead
- Loading branch information
Showing
7 changed files
with
56 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
import $$observable from 'symbol-observable' | ||
import createEagerFactory from './createEagerFactory' | ||
import createHelper from './createHelper' | ||
import componentFromStream from './componentFromStream' | ||
|
||
const mapPropsStream = transform => BaseComponent => { | ||
const factory = createEagerFactory(BaseComponent) | ||
return componentFromStream(ownerProps$ => | ||
new Observable(observer => { | ||
return componentFromStream(ownerProps$ => ({ | ||
subscribe(observer) { | ||
const subscription = transform(ownerProps$).subscribe({ | ||
next: childProps => observer.next(factory(childProps)) | ||
}) | ||
return () => subscription.unsubscribe() | ||
}) | ||
) | ||
return { | ||
unsubscribe: () => subscription.unsubscribe() | ||
} | ||
}, | ||
[$$observable]() { | ||
return this | ||
} | ||
})) | ||
} | ||
|
||
export default createHelper(mapPropsStream, 'mapPropsStream') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters