react-rx 2.1.3 → 3.0.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/WithObservable.d.ts +1 -1
- package/dist/cjs/__tests__/strictmode.test.js +43 -18
- package/dist/cjs/__tests__/useAsObservable.test.js +12 -11
- package/dist/cjs/__tests__/useObservable.test.js +31 -30
- package/dist/cjs/reactiveComponent.d.ts +2 -2
- package/dist/cjs/useObservable.js +16 -48
- package/dist/es2015/WithObservable.d.ts +1 -1
- package/dist/es2015/__tests__/strictmode.test.js +34 -9
- package/dist/es2015/__tests__/useAsObservable.test.js +1 -0
- package/dist/es2015/__tests__/useObservable.test.js +1 -0
- package/dist/es2015/reactiveComponent.d.ts +2 -2
- package/dist/es2015/useObservable.js +18 -50
- package/dist/esm/WithObservable.d.ts +1 -1
- package/dist/esm/__tests__/strictmode.test.js +35 -10
- package/dist/esm/__tests__/useAsObservable.test.js +1 -0
- package/dist/esm/__tests__/useObservable.test.js +1 -0
- package/dist/esm/reactiveComponent.d.ts +2 -2
- package/dist/esm/useObservable.js +18 -50
- package/package.json +21 -27
- package/src/__tests__/strictmode.test.ts +37 -9
- package/src/__tests__/useAsObservable.test.tsx +1 -0
- package/src/__tests__/useObservable.test.tsx +1 -0
- package/src/useObservable.ts +20 -70
- package/src/utils.ts +1 -1
- package/dist/cjs/withPropsStream.d.ts +0 -8
- package/dist/cjs/withPropsStream.js +0 -55
- package/dist/es2015/withPropsStream.d.ts +0 -8
- package/dist/es2015/withPropsStream.js +0 -17
- package/dist/esm/withPropsStream.d.ts +0 -8
- package/dist/esm/withPropsStream.js +0 -28
- package/src/withPropsStream.tsx +0 -27
package/src/withPropsStream.tsx
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import {Observable} from 'rxjs'
|
|
3
|
-
import {map} from 'rxjs/operators'
|
|
4
|
-
import {wrapDisplayName} from './displayName'
|
|
5
|
-
import {reactiveComponent} from './reactiveComponent'
|
|
6
|
-
|
|
7
|
-
type ObservableFactory<SourceProps, TargetProps> = (
|
|
8
|
-
props$: Observable<SourceProps>,
|
|
9
|
-
) => Observable<TargetProps>
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use reactiveComponent instead
|
|
13
|
-
*/
|
|
14
|
-
export function withPropsStream<SourceProps, TargetProps>(
|
|
15
|
-
observableOrFactory: Observable<TargetProps> | ObservableFactory<SourceProps, TargetProps>,
|
|
16
|
-
TargetComponent: React.ComponentType<TargetProps>,
|
|
17
|
-
) {
|
|
18
|
-
const ComposedComponent = reactiveComponent<SourceProps>(sourceProps$ => {
|
|
19
|
-
const targetProps$ =
|
|
20
|
-
typeof observableOrFactory === 'function'
|
|
21
|
-
? observableOrFactory(sourceProps$)
|
|
22
|
-
: observableOrFactory
|
|
23
|
-
return targetProps$.pipe(map(props => <TargetComponent {...props} />))
|
|
24
|
-
})
|
|
25
|
-
ComposedComponent.displayName = wrapDisplayName(TargetComponent, 'withPropsStream')
|
|
26
|
-
return ComposedComponent
|
|
27
|
-
}
|