redux-zero
Advanced tools
Comparing version 4.15.2 to 5.0.0
# Changelog | ||
### 5.0.0 | ||
**BREAKING CHANGES** | ||
- Add generics to `bindActions()` , `connect()` , `createStore()` , `Provider` , `Store` . | ||
- Default: any | ||
note: | ||
If using createStore() with partial initial state, it will inferred to incorrect type. | ||
```tsx | ||
import createStore from "redux-zero"; | ||
interface ReduxState { | ||
a: number; | ||
b: number; | ||
} | ||
const store = createStore({a: 3}); // Store<{a: 3}> | ||
const store = createStore<ReduxState>({a: 3}); // Store<Partial<ReduxState>> | ||
const store = createStore<ReduxState>({a: 3, b: 3}); // Store<ReduxState> | ||
``` | ||
### 4.15.2 | ||
@@ -4,0 +26,0 @@ |
@@ -41,4 +41,4 @@ import Store from "../interfaces/Store"; | ||
declare function getOrAddAction(action: Action, fn: Function): NextAction; | ||
declare function update(message: Message): void; | ||
declare const devtoolsMiddleware: (store: Store) => (next: Function, args: any) => (action: Action) => any; | ||
declare function update<T extends Store>(this: T, message: Message): void; | ||
declare const devtoolsMiddleware: (store: Store<any>) => (next: Function, args: any) => (action: Action) => any; | ||
export { devtoolsMiddleware, connect, update, devTools, getOrAddAction }; |
/// <reference types="react" /> | ||
import Store from "./Store"; | ||
export default interface Props { | ||
store: Store; | ||
export default interface Props<S = any> { | ||
store: Store<S>; | ||
children: JSX.Element[] | JSX.Element; | ||
} |
@@ -1,7 +0,7 @@ | ||
export default interface Store { | ||
export default interface Store<S = any> { | ||
middleware(...args: any[]): void; | ||
setState(f: Function | object): void; | ||
setState(f: ((state: S) => Partial<S>) | Partial<S>): void; | ||
subscribe(f: Function): () => void; | ||
getState(): object; | ||
getState(): S; | ||
reset(): void; | ||
} |
import Store from "../interfaces/Store"; | ||
export default function applyMiddleware(...middlewares: any[]): (store: Store, action: Function, args: any) => any; | ||
export default function applyMiddleware(...middlewares: any[]): (store: Store<any>, action: Function, args: any) => any; |
{ | ||
"name": "redux-zero", | ||
"version": "4.15.2", | ||
"version": "5.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/redux-zero.js", |
@@ -5,7 +5,11 @@ import { Component } from "preact"; | ||
state: any; | ||
actions: any; | ||
actions: { | ||
[x: string]: (...args: any[]) => void | Promise<void>; | ||
}; | ||
componentWillMount(): void; | ||
componentWillUnmount(): void; | ||
getProps(): any; | ||
getActions(): any; | ||
getActions(): { | ||
[x: string]: (...args: any[]) => void | Promise<void>; | ||
}; | ||
update: () => void; | ||
@@ -12,0 +16,0 @@ render({ children }: { |
import { Component } from "preact"; | ||
import Props from "../../interfaces/Props"; | ||
import Store from "../../interfaces/Store"; | ||
export default class Provider extends Component<Props, {}> { | ||
export default class Provider<S = any> extends Component<Props<S>, {}> { | ||
getChildContext(): { | ||
store: Store; | ||
store: Store<S>; | ||
}; | ||
render(): JSX.Element; | ||
} |
import * as React from "react"; | ||
import propValidation from "../../utils/propsValidation"; | ||
declare type mapToProps = (state: object, ownProps?: object) => object; | ||
declare type mapToProps<S> = (state: S, ownProps?: object) => object; | ||
export declare class Connect extends React.Component<any> { | ||
@@ -10,11 +10,15 @@ static contextTypes: { | ||
state: any; | ||
actions: any; | ||
actions: { | ||
[x: string]: (...args: any[]) => void | Promise<void>; | ||
}; | ||
componentWillMount(): void; | ||
componentWillUnmount(): void; | ||
getProps(): any; | ||
getActions(): any; | ||
getActions(): { | ||
[x: string]: (...args: any[]) => void | Promise<void>; | ||
}; | ||
update: () => void; | ||
render(): any; | ||
} | ||
export default function connect(mapToProps?: mapToProps, actions?: {}): (Child: any) => { | ||
export default function connect<S = any>(mapToProps?: mapToProps<S>, actions?: {}): (Child: any) => { | ||
new (props?: any, context?: any): { | ||
@@ -21,0 +25,0 @@ render(): JSX.Element; |
@@ -5,3 +5,3 @@ import * as React from "react"; | ||
import Store from "../../interfaces/Store"; | ||
export default class Provider extends React.Component<Props> { | ||
export default class Provider<S = any> extends React.Component<Props<S>> { | ||
static childContextTypes: { | ||
@@ -11,5 +11,5 @@ store: typeof propValidation; | ||
getChildContext(): { | ||
store: Store; | ||
store: Store<S>; | ||
}; | ||
render(): React.ReactElement<any>; | ||
} |
import Store from "../interfaces/Store"; | ||
export default function createStore(initialState?: object, middleware?: any): Store; | ||
declare function createStore<S extends object = any>(): Store<Partial<S>>; | ||
declare function createStore<S extends object = any>(initialState?: S, middleware?: any): Store<S>; | ||
declare function createStore<S extends object = any>(initialState?: Partial<S>, middleware?: any): Store<Partial<S>>; | ||
export default createStore; |
@@ -0,5 +1,10 @@ | ||
import { Action } from "../../utils/bindActions"; | ||
import Store from "../../interfaces/Store"; | ||
declare type mapToProps = (state: object, ownProps?: object) => object; | ||
export declare function getActions(store: Store, actions: Function): any; | ||
export declare function getActions<S>(store: Store<S>, actions: { | ||
[key: string]: Action<S>; | ||
}): { | ||
[x: string]: (...args: any[]) => void | Promise<void>; | ||
}; | ||
export declare function connect(component: any, store: Store, mapToProps: mapToProps): void; | ||
export {}; |
import Store from "../interfaces/Store"; | ||
export default function bindActions(actions: Function, store: Store, ownProps?: object): any; | ||
export declare type Action<S> = (state: S, ...args: any[]) => Partial<S>; | ||
export default function bindActions<S, T extends { | ||
[key: string]: Action<S>; | ||
}>(actions: ((store: Store<S>, ownProps: any) => T) | T, store: Store<S>, ownProps?: object): { | ||
[K in keyof T]: (...args: any[]) => Promise<void> | void; | ||
}; |
import Store from "../interfaces/Store"; | ||
export default function set(store: Store, ret: any): any; | ||
export default function set(store: Store, ret: any): Promise<void> | void; |
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
67971
988