-
-
Save AllGistsEqual/ded6ebf9bad0c176e7686073427932ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File: src/redux/ducks/appState.ts | |
import { createAction, createReducer } from '@reduxjs/toolkit' | |
import { RootState } from '../index' | |
type AppState = { | |
isRunning: boolean | |
} | |
const initialState: AppState = { | |
isRunning: false, | |
} | |
export const setRunning = createAction('[APPSTATE] Set Running', (running: boolean) => ({ | |
payload: { | |
running, | |
}, | |
})) | |
export const selectIsRunning = (state: RootState): boolean => state.appState.isRunning | |
const appStateReducer = createReducer(initialState, builder => { | |
builder.addCase(setRunning, (state, action) => { | |
const { running } = action.payload | |
return { | |
isRunning: running, | |
} | |
}) | |
}) | |
export default appStateReducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment