Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
redux アプリで定期実行処理を書くには / ミドルウェア
function businessLogic(store: any): {stopFlag: boolean} {
// なんらかのビジネスロジックを記述
// ミドルウェアでは次のようにステートを取り出せます。
// const stateName = store.getState().stateName;
return { stopFlag: false };
}
export default (store: any) => (next: any) => (action: any) => {
if (action.type === ActionTypes.CHECK_SAMPLE_EXEC) {
if (businessLogic(store).stopFlag) {
next(stop());
}
}
next(action);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment