refract-redux-rxjs
Advanced tools
Comparing version 1.0.0-3 to 1.0.0-4
@@ -29,4 +29,3 @@ import { from, Observable } from 'rxjs'; | ||
var storeObservable = from(store); | ||
return function (actionOrSelector, opts) { | ||
var options = __assign({ initialValue: true }, opts); | ||
return function (actionOrSelector) { | ||
if (typeof actionOrSelector === 'string') { | ||
@@ -39,9 +38,3 @@ return Observable.create(function (listener) { | ||
if (typeof actionOrSelector === 'function') { | ||
var operators = [ | ||
map(actionOrSelector), | ||
options.initialValue && | ||
startWith(actionOrSelector(store.getState())), | ||
distinctUntilChanged() | ||
].filter(Boolean); | ||
return storeObservable.pipe.apply(storeObservable, operators); | ||
return storeObservable.pipe(map(actionOrSelector), startWith(actionOrSelector(store.getState())), distinctUntilChanged()); | ||
} | ||
@@ -48,0 +41,0 @@ }; |
11
index.js
@@ -33,4 +33,3 @@ 'use strict'; | ||
var storeObservable = rxjs.from(store); | ||
return function (actionOrSelector, opts) { | ||
var options = __assign({ initialValue: true }, opts); | ||
return function (actionOrSelector) { | ||
if (typeof actionOrSelector === 'string') { | ||
@@ -43,9 +42,3 @@ return rxjs.Observable.create(function (listener) { | ||
if (typeof actionOrSelector === 'function') { | ||
var operators$$1 = [ | ||
operators.map(actionOrSelector), | ||
options.initialValue && | ||
operators.startWith(actionOrSelector(store.getState())), | ||
operators.distinctUntilChanged() | ||
].filter(Boolean); | ||
return storeObservable.pipe.apply(storeObservable, operators$$1); | ||
return storeObservable.pipe(operators.map(actionOrSelector), operators.startWith(actionOrSelector(store.getState())), operators.distinctUntilChanged()); | ||
} | ||
@@ -52,0 +45,0 @@ }; |
{ | ||
"name": "refract-redux-rxjs", | ||
"version": "1.0.0-3", | ||
"version": "1.0.0-4", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "jsnext:main": "index.es.js", |
@@ -11,5 +11,1 @@ export interface EnhancerOptions { | ||
export type Selector<T> = (state: object) => T | ||
export interface ObserveOptions { | ||
initialValue: boolean | ||
} |
import refractEnhancer from './refractEnhancer' | ||
import { EnhancerOptions, ObserveOptions } from './baseTypes' | ||
import { EnhancerOptions } from './baseTypes' | ||
export { refractEnhancer, EnhancerOptions, ObserveOptions } | ||
export { refractEnhancer, EnhancerOptions } |
import { from, Observable, PartialObserver as Listener } from 'rxjs' | ||
import { map, distinctUntilChanged, startWith } from 'rxjs/operators' | ||
import { Selector, ObserveOptions } from './baseTypes' | ||
import { Selector } from './baseTypes' | ||
import { Store } from 'redux' | ||
export interface ObserveFn { | ||
<T>( | ||
actionTypeOrListener: string | Selector<T>, | ||
options?: Partial<ObserveOptions> | ||
): Observable<T> | ||
<T>(actionTypeOrListener: string | Selector<T>): Observable<T> | ||
} | ||
@@ -16,7 +13,3 @@ | ||
return <T>(actionOrSelector, opts?: Partial<ObserveOptions>) => { | ||
const options: ObserveOptions = { | ||
initialValue: true, | ||
...opts | ||
} | ||
return <T>(actionOrSelector) => { | ||
if (typeof actionOrSelector === 'string') { | ||
@@ -34,12 +27,9 @@ return Observable.create((listener: Partial<Listener<T>>) => { | ||
if (typeof actionOrSelector === 'function') { | ||
const operators = [ | ||
return storeObservable.pipe<T>( | ||
map(actionOrSelector), | ||
options.initialValue && | ||
startWith(actionOrSelector(store.getState())), | ||
startWith(actionOrSelector(store.getState())), | ||
distinctUntilChanged<T>() | ||
].filter(Boolean) | ||
return storeObservable.pipe<T>(...operators) | ||
) | ||
} | ||
} | ||
} |
@@ -11,4 +11,1 @@ export interface EnhancerOptions { | ||
export declare type Selector<T> = (state: object) => T | ||
export interface ObserveOptions { | ||
initialValue: boolean | ||
} |
import refractEnhancer from './refractEnhancer' | ||
import { EnhancerOptions, ObserveOptions } from './baseTypes' | ||
export { refractEnhancer, EnhancerOptions, ObserveOptions } | ||
import { EnhancerOptions } from './baseTypes' | ||
export { refractEnhancer, EnhancerOptions } |
import { Observable } from 'rxjs' | ||
import { Selector, ObserveOptions } from './baseTypes' | ||
import { Selector } from './baseTypes' | ||
export interface ObserveFn { | ||
<T>( | ||
actionTypeOrListener: string | Selector<T>, | ||
options?: Partial<ObserveOptions> | ||
): Observable<T> | ||
<T>(actionTypeOrListener: string | Selector<T>): Observable<T> | ||
} | ||
export declare const observeFactory: (store: any) => ObserveFn |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
16828
14
1
113
310