adding redux reliance

This commit is contained in:
Jiayu Liu
2018-06-27 00:27:41 +08:00
parent 4d7932fa69
commit 83d379d813
2 changed files with 18 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;
+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: {