refract-redux-rxjs
Advanced tools
Comparing version 1.0.0-0 to 1.0.0-1
@@ -29,7 +29,7 @@ import { from, Observable } from 'rxjs'; | ||
var storeObservable = from(store); | ||
return function (actionOrSelector, withInitialValue) { | ||
if (withInitialValue === void 0) { withInitialValue = true; } | ||
return function (actionOrSelector, opts) { | ||
var options = __assign({ initialValue: true }, opts); | ||
if (typeof actionOrSelector === 'string') { | ||
return Observable.create(function (Listener) { | ||
var unsubscribe = store.addActionListener(actionOrSelector); | ||
return Observable.create(function (listener) { | ||
var unsubscribe = store.addActionListener(actionOrSelector, listener.next.bind(listener)); | ||
return unsubscribe; | ||
@@ -41,3 +41,3 @@ }); | ||
map(actionOrSelector), | ||
withInitialValue && | ||
options.initialValue && | ||
startWith(actionOrSelector(store.getState())), | ||
@@ -44,0 +44,0 @@ distinctUntilChanged() |
10
index.js
@@ -33,7 +33,7 @@ 'use strict'; | ||
var storeObservable = rxjs.from(store); | ||
return function (actionOrSelector, withInitialValue) { | ||
if (withInitialValue === void 0) { withInitialValue = true; } | ||
return function (actionOrSelector, opts) { | ||
var options = __assign({ initialValue: true }, opts); | ||
if (typeof actionOrSelector === 'string') { | ||
return rxjs.Observable.create(function (Listener) { | ||
var unsubscribe = store.addActionListener(actionOrSelector); | ||
return rxjs.Observable.create(function (listener) { | ||
var unsubscribe = store.addActionListener(actionOrSelector, listener.next.bind(listener)); | ||
return unsubscribe; | ||
@@ -45,3 +45,3 @@ }); | ||
operators.map(actionOrSelector), | ||
withInitialValue && | ||
options.initialValue && | ||
operators.startWith(actionOrSelector(store.getState())), | ||
@@ -48,0 +48,0 @@ operators.distinctUntilChanged() |
{ | ||
"name": "refract-redux-rxjs", | ||
"version": "1.0.0-0", | ||
"version": "1.0.0-1", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "jsnext:main": "index.es.js", |
@@ -11,1 +11,5 @@ export interface EnhancerOptions { | ||
export type Selector<T> = (state: object) => T | ||
export interface ObserveOptions { | ||
initialValue: boolean | ||
} |
import refractEnhancer from './refractEnhancer' | ||
import { EnhancerOptions } from './baseTypes' | ||
import { EnhancerOptions, ObserveOptions } from './baseTypes' | ||
export { refractEnhancer, EnhancerOptions } | ||
export { refractEnhancer, EnhancerOptions, ObserveOptions } |
import { from, Observable, PartialObserver as Listener } from 'rxjs' | ||
import { map, distinctUntilChanged, startWith } from 'rxjs/operators' | ||
import { Selector } from './baseTypes' | ||
import { Selector, ObserveOptions } from './baseTypes' | ||
import { Store } from 'redux' | ||
@@ -9,3 +9,3 @@ | ||
actionTypeOrListener: string | Selector<T>, | ||
withInitialValue?: boolean | ||
options: Partial<ObserveOptions> | ||
): Observable<T> | ||
@@ -17,6 +17,13 @@ } | ||
return <T>(actionOrSelector, withInitialValue = true) => { | ||
return <T>(actionOrSelector, opts: Partial<ObserveOptions>) => { | ||
const options: ObserveOptions = { | ||
initialValue: true, | ||
...opts | ||
} | ||
if (typeof actionOrSelector === 'string') { | ||
return Observable.create((Listener: Partial<Listener<T>>) => { | ||
const unsubscribe = store.addActionListener(actionOrSelector) | ||
return Observable.create((listener: Partial<Listener<T>>) => { | ||
const unsubscribe = store.addActionListener( | ||
actionOrSelector, | ||
listener.next.bind(listener) | ||
) | ||
@@ -30,3 +37,3 @@ return unsubscribe | ||
map(actionOrSelector), | ||
withInitialValue && | ||
options.initialValue && | ||
startWith(actionOrSelector(store.getState())), | ||
@@ -33,0 +40,0 @@ distinctUntilChanged<T>() |
@@ -11,1 +11,4 @@ export interface EnhancerOptions { | ||
export declare type Selector<T> = (state: object) => T | ||
export interface ObserveOptions { | ||
initialValue: boolean | ||
} |
import refractEnhancer from './refractEnhancer' | ||
import { EnhancerOptions } from './baseTypes' | ||
export { refractEnhancer, EnhancerOptions } | ||
import { EnhancerOptions, ObserveOptions } from './baseTypes' | ||
export { refractEnhancer, EnhancerOptions, ObserveOptions } |
import { Observable } from 'rxjs' | ||
import { Selector } from './baseTypes' | ||
import { Selector, ObserveOptions } from './baseTypes' | ||
export interface ObserveFn { | ||
<T>( | ||
actionTypeOrListener: string | Selector<T>, | ||
withInitialValue?: boolean | ||
options: Partial<ObserveOptions> | ||
): 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
13782
342