Add voiceSlice redux slice for voice icon state

This commit is contained in:
Ceda EI 2021-01-04 00:58:07 +05:30
parent 66d688291c
commit 2c80c4b279
2 changed files with 19 additions and 0 deletions

View File

@ -1,8 +1,10 @@
import { configureStore } from "@reduxjs/toolkit"; import { configureStore } from "@reduxjs/toolkit";
import coreReducer from "../coreSlice"; import coreReducer from "../coreSlice";
import voiceReducer from "../voiceSlice";
export default configureStore({ export default configureStore({
reducer: { reducer: {
core: coreReducer, core: coreReducer,
voice: voiceReducer,
}, },
}); });

17
src/voiceSlice.js Normal file
View File

@ -0,0 +1,17 @@
import { createSlice } from "@reduxjs/toolkit";
export const voiceSlice = createSlice({
name: "voice",
initialState: {
recording: false,
text: null
},
reducers: {
setRecording: (state, action) => ({...state, recording: action.payload}),
setText: (state, action) => ({...state, text: action.payload}),
}
});
export const { setRecording, setText } = voiceSlice.actions;
export const selectVoice = state => state.voice;
export default voiceSlice.reducer;