Merge pull request #26868 from Jimexist/add-wepy-redux

update wepy-redux typing to add getStore / setStore
This commit is contained in:
Paul van Brenk
2018-06-27 10:32:16 -07:00
committed by GitHub
3 changed files with 24 additions and 3 deletions
+5 -2
View File
@@ -2,9 +2,10 @@
// Project: https://github.com/Tencent/wepy/tree/1.7.x/packages/wepy-redux
// Definitions by: Jiayu Liu <https://github.com/Jimexist>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.3
import wepy from "wepy";
import { Store } from "redux";
export interface MapStateToProps {
[propName: string]: ((state: any) => any) | string;
@@ -18,4 +19,6 @@ export function connect(
mapDispatchToProps: MapDispatchToProps
): (<T extends wepy.Component>(original: T) => T);
export function setStore(store: any): void;
export function setStore(store: Store): void;
export function getStore(): Store;
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"redux": "^4.0.0"
}
}
+13 -1
View File
@@ -1,5 +1,17 @@
import wepy from "wepy";
import { connect } from "wepy-redux";
import { createStore } from "redux";
import { connect, getStore, setStore } from "wepy-redux";
const store = createStore(
(counter: number | undefined, action: { type: string; payload: number }) =>
counter || 0 + action.payload,
0
);
setStore(store);
const s = getStore();
s.dispatch({ type: "a" });
interface State {
counter: {