refract-rxjs
Advanced tools
Comparing version 4.1.2 to 4.2.0
@@ -72,3 +72,5 @@ import { from } from 'rxjs'; | ||
}; }; | ||
var isProps = function (data) { return data.type === DataType.PROPS; }; | ||
var isProps = function (data) { | ||
return data.type === DataType.PROPS; | ||
}; | ||
var isCallback = function (propName) { return function (data) { | ||
@@ -75,0 +77,0 @@ return data.type === DataType.CALLBACK && |
@@ -76,3 +76,5 @@ 'use strict'; | ||
}; }; | ||
var isProps = function (data) { return data.type === DataType.PROPS; }; | ||
var isProps = function (data) { | ||
return data.type === DataType.PROPS; | ||
}; | ||
var isCallback = function (propName) { return function (data) { | ||
@@ -79,0 +81,0 @@ return data.type === DataType.CALLBACK && |
{ | ||
"name": "refract-rxjs", | ||
"description": "Refract bindings for React with RxJS: harness the power of reactive programming to supercharge your components!", | ||
"version": "4.1.2", | ||
"version": "4.2.0", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "jsnext:main": "index.es.js", |
@@ -1,12 +0,12 @@ | ||
export declare type Handler<P, E, C = any> = ( | ||
intialProps: P, | ||
initialContext?: C | ||
) => (val: E) => void | ||
export declare type ErrorHandler<P, C = any> = ( | ||
intialProps: P, | ||
initialContext?: C | ||
export declare type Handler<Props, Effect, Context = any> = ( | ||
intialProps: Props, | ||
initialContext?: Context | ||
) => (val: Effect) => void | ||
export declare type ErrorHandler<Props, Context = any> = ( | ||
intialProps: Props, | ||
initialContext?: Context | ||
) => (error: any) => void | ||
export interface PushEvent { | ||
(eventName: string): () => void | ||
<T = any>(eventName: string): (val: T) => void | ||
<Event = any>(eventName: string): (val: Event) => void | ||
} |
export declare const compose: Compose | ||
export interface Compose { | ||
<R>(...fns: Function[]): (arg: any) => R | ||
<A, R>(f: (arg: A) => R): (arg: A) => R | ||
<A, B, R>(f: (arg: B) => R, g: (arg: A) => B): (arg: A) => R | ||
<A, B, C, R>(f: (arg: C) => R, g: (arg: B) => C, h: (arg: A) => B): ( | ||
arg: A | ||
) => R | ||
<A, B, C, D, R>( | ||
f: (arg: D) => R, | ||
<Result>(...fns: Function[]): (arg: any) => Result | ||
<A, Result>(f: (arg: A) => Result): (arg: A) => Result | ||
<A, B, Result>(f: (arg: B) => Result, g: (arg: A) => B): (arg: A) => Result | ||
<A, B, C, Result>( | ||
f: (arg: C) => Result, | ||
g: (arg: B) => C, | ||
h: (arg: A) => B | ||
): (arg: A) => Result | ||
<A, B, C, D, Result>( | ||
f: (arg: D) => Result, | ||
g: (arg: C) => D, | ||
h: (arg: B) => C, | ||
i: (arg: A) => B | ||
): (arg: A) => R | ||
<A, B, C, D, E, R>( | ||
f: (arg: E) => R, | ||
): (arg: A) => Result | ||
<A, B, C, D, E, Result>( | ||
f: (arg: E) => Result, | ||
g: (arg: D) => E, | ||
@@ -21,5 +23,5 @@ h: (arg: C) => D, | ||
j: (arg: A) => B | ||
): (arg: A) => R | ||
<A, B, C, D, E, F, R>( | ||
f: (arg: F) => R, | ||
): (arg: A) => Result | ||
<A, B, C, D, E, F, Result>( | ||
f: (arg: F) => Result, | ||
g: (arg: E) => F, | ||
@@ -30,5 +32,5 @@ h: (arg: D) => E, | ||
k: (arg: A) => B | ||
): (arg: A) => R | ||
<A, B, C, D, E, F, G, R>( | ||
f: (arg: G) => R, | ||
): (arg: A) => Result | ||
<A, B, C, D, E, F, G, Result>( | ||
f: (arg: G) => Result, | ||
g: (arg: F) => G, | ||
@@ -40,5 +42,5 @@ h: (arg: E) => F, | ||
l: (arg: A) => B | ||
): (arg: A) => R | ||
<A, B, C, D, E, F, G, H, R>( | ||
f: (arg: H) => R, | ||
): (arg: A) => Result | ||
<A, B, C, D, E, F, G, H, Result>( | ||
f: (arg: H) => Result, | ||
g: (arg: G) => H, | ||
@@ -51,3 +53,3 @@ h: (arg: F) => G, | ||
m: (arg: A) => B | ||
): (arg: A) => R | ||
): (arg: A) => Result | ||
} |
import { Handler, ErrorHandler } from './baseTypes' | ||
import { Aperture } from './observable' | ||
declare const configureComponent: <P, E, Ctx>( | ||
aperture: Aperture<P, E, Ctx>, | ||
declare const configureComponent: <Props, Effect, Context>( | ||
aperture: Aperture<Props, Effect, Context>, | ||
instance: any, | ||
isValidElement?: (val: any) => boolean, | ||
isComponentClass?: (val: any) => boolean, | ||
handler?: Handler<P, E, Ctx>, | ||
errorHandler?: ErrorHandler<P, any>, | ||
handler?: Handler<Props, Effect, Context>, | ||
errorHandler?: ErrorHandler<Props, any>, | ||
mergeProps?: boolean, | ||
@@ -11,0 +11,0 @@ decorateProps?: boolean |
import { Aperture } from './observable' | ||
import { Handler, ErrorHandler } from './baseTypes' | ||
export declare const configureHook: <D, E>( | ||
aperture: Aperture<D, E, any>, | ||
data: D, | ||
handler?: Handler<D, E, any>, | ||
errorHandler?: ErrorHandler<D, any> | ||
export declare const configureHook: <Data, Effect>( | ||
aperture: Aperture<Data, Effect, any>, | ||
data: Data, | ||
handler?: Handler<Data, Effect, any>, | ||
errorHandler?: ErrorHandler<Data, any> | ||
) => { | ||
@@ -12,4 +12,4 @@ data: any | ||
pushMountEvent: () => void | ||
pushData: (data: D) => void | ||
pushData: (data: Data) => void | ||
registerSetData: (setData: any) => void | ||
} |
@@ -8,6 +8,6 @@ export declare const MOUNT_EVENT: string | ||
} | ||
export declare type Data<P> = PropsData<P> | CallbackData | EventData | ||
export interface PropsData<P> { | ||
export declare type Data<Props> = PropsData<Props> | CallbackData | EventData | ||
export interface PropsData<Props> { | ||
type: DataType | ||
payload: Partial<P> | ||
payload: Partial<Props> | ||
} | ||
@@ -28,11 +28,11 @@ export interface CallbackData { | ||
} | ||
export declare const isEvent: <P>( | ||
export declare const isEvent: <Props>( | ||
eventName: any | ||
) => (data: Data<P>, index?: any) => boolean | ||
export declare const isProps: <P>(data: Data<P>) => boolean | ||
export declare const isCallback: <P>( | ||
) => (data: Data<Props>, index?: any) => boolean | ||
export declare const isProps: <Props>(data: Data<Props>) => boolean | ||
export declare const isCallback: <Props>( | ||
propName: any | ||
) => (data: Data<P>) => boolean | ||
) => (data: Data<Props>) => boolean | ||
export declare const createEventData: (name: string, value?: any) => EventData | ||
export declare const createPropsData: <P>(props: P) => PropsData<P> | ||
export declare const createPropsData: <Props>(props: Props) => PropsData<Props> | ||
export declare const createCallbackData: ( | ||
@@ -39,0 +39,0 @@ name: string, |
export declare const PROPS_EFFECT: string | ||
export declare const COMPONENT_EFFECT: string | ||
export interface PropEffect<P = object> { | ||
export interface PropEffect<Props = object> { | ||
type: string | ||
payload: { | ||
replace: boolean | ||
props: P | ||
props: Props | ||
} | ||
} | ||
export interface ComponentEffect<D = object> { | ||
export interface ComponentEffect<Data = object> { | ||
type: string | ||
payload: D | ||
payload: Data | ||
} | ||
export declare const toProps: <P>(props: P) => PropEffect<P> | ||
export declare const asProps: <P>(props: P) => PropEffect<P> | ||
export declare const toRender: <D>(data: D) => ComponentEffect<D> | ||
export declare const toProps: <Props>(props: Props) => PropEffect<Props> | ||
export declare const asProps: <Props>(props: Props) => PropEffect<Props> | ||
export declare const toRender: <Data>(data: Data) => ComponentEffect<Data> |
@@ -6,5 +6,5 @@ import { Observable, PartialObserver as Listener, Subscription } from 'rxjs' | ||
(eventName: string): [Observable<void>, () => any] | ||
<T = any>(eventName: string, seedValue?: T): [ | ||
Observable<T>, | ||
(val: T) => any | ||
<Type = any>(eventName: string, seedValue?: Type): [ | ||
Observable<Type>, | ||
(val: Type) => any | ||
] | ||
@@ -14,3 +14,6 @@ } | ||
(eventName: string): Observable<void> | ||
<T>(eventName: string, valueTransformer?: (val: any) => T): Observable<T> | ||
<Type>( | ||
eventName: string, | ||
valueTransformer?: (val: any) => Type | ||
): Observable<Type> | ||
} | ||
@@ -25,16 +28,16 @@ export interface ObservableComponentBase { | ||
export interface Observe { | ||
observe: <T>( | ||
observe: <Type>( | ||
propName?: string, | ||
valueTransformer?: (val: any) => T | ||
) => Observable<T> | ||
valueTransformer?: (val: any) => Type | ||
) => Observable<Type> | ||
} | ||
export declare type ObservableComponent = Observe & ObservableComponentBase | ||
export declare type Aperture<P, E, C = any> = ( | ||
export declare type Aperture<Props, Effect, Context = any> = ( | ||
component: ObservableComponent, | ||
initialProps: P, | ||
initialContext?: C | ||
) => Observable<E> | ||
export declare const subscribeToSink: <T>( | ||
sink: Observable<T>, | ||
next: (val: T) => void, | ||
initialProps: Props, | ||
initialContext?: Context | ||
) => Observable<Effect> | ||
export declare const subscribeToSink: <Type>( | ||
sink: Observable<Type>, | ||
next: (val: Type) => void, | ||
error?: (error: any) => void | ||
@@ -48,8 +51,8 @@ ) => Subscription | ||
} | ||
export declare const getObserve: <P>( | ||
export declare const getObserve: <Props>( | ||
getProp: any, | ||
data: any, | ||
decoratedProps: any | ||
) => <T>(propName?: any, valueTransformer?: any) => any | ||
export declare const createComponent: <P>( | ||
) => <Type>(propName?: any, valueTransformer?: any) => any | ||
export declare const createComponent: <Props>( | ||
getProp: any, | ||
@@ -56,0 +59,0 @@ dataObservable: any, |
import { Aperture } from './observable' | ||
import { Handler, ErrorHandler } from './baseTypes' | ||
export interface Config<D, E> { | ||
handler?: Handler<D, E> | ||
errorHandler?: ErrorHandler<D> | ||
export interface Config<Data, Effect> { | ||
handler?: Handler<Data, Effect> | ||
errorHandler?: ErrorHandler<Data> | ||
} | ||
export declare const useRefract: <D, CD = any, E = any>( | ||
aperture: Aperture<D, E, any>, | ||
data: D, | ||
config?: Config<D, E> | ||
) => CD | ||
export declare const useRefract: <Data, CurrentData = any, Effect = any>( | ||
aperture: Aperture<Data, Effect, any>, | ||
data: Data, | ||
config?: Config<Data, Effect> | ||
) => CurrentData |
@@ -11,18 +11,23 @@ /// <reference types="react" /> | ||
} | ||
export interface Config<P, E, C = any> { | ||
handler?: Handler<P, E, C> | ||
errorHandler?: ErrorHandler<P, C> | ||
Context?: React.Context<C> | ||
export interface Config<Props, Effect, Context = any> { | ||
handler?: Handler<Props, Effect, Context> | ||
errorHandler?: ErrorHandler<Props, Context> | ||
Context?: React.Context<Context> | ||
mergeProps?: boolean | ||
decorateProps?: boolean | ||
} | ||
export declare const withEffects: <P, E, CP = P, C = any>( | ||
aperture: Aperture<P, E, C>, | ||
config?: Config<P, E, C> | ||
export declare const withEffects: < | ||
Props, | ||
Effect, | ||
ChildProps = Props, | ||
Context = any | ||
>( | ||
aperture: Aperture<Props, Effect, Context>, | ||
config?: Config<Props, Effect, Context> | ||
) => ( | ||
BaseComponent?: React.ComponentType< | ||
CP & { | ||
ChildProps & { | ||
pushEvent: PushEvent | ||
} | ||
> | ||
) => React.ComponentClass<P, any> | ||
) => React.ComponentClass<Props, any> |
52619
1179