DefinitelyTyped/types/wepy-redux/wepy-redux-tests.ts
2018-06-27 00:27:41 +08:00

42 lines
741 B
TypeScript

import wepy from "wepy";
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: {
num: number;
};
}
@connect(
{
num(state: State) {
return state.counter.num;
},
inc: "inc"
},
{
addNum: "INCREMENT",
asyncInc: () => {}
}
)
export default class Index extends wepy.page {
// methods
methods = {
// method values
};
// on load
onLoad() {}
}