From ad9f5ac81619d6ea49c665a07a01304c138ffad3 Mon Sep 17 00:00:00 2001 From: Dragos676 <109582187+Dragos676@users.noreply.github.com> Date: Fri, 22 Jul 2022 18:20:26 +0300 Subject: [PATCH] Delete src/store directory --- src/store/configureStore.ts | 10 ---- src/store/modules/counter.ts | 25 --------- src/store/modules/index.ts | 14 ----- src/store/modules/todos.ts | 99 ------------------------------------ 4 files changed, 148 deletions(-) delete mode 100644 src/store/configureStore.ts delete mode 100644 src/store/modules/counter.ts delete mode 100644 src/store/modules/index.ts delete mode 100644 src/store/modules/todos.ts diff --git a/src/store/configureStore.ts b/src/store/configureStore.ts deleted file mode 100644 index 5439119..0000000 --- a/src/store/configureStore.ts +++ /dev/null @@ -1,10 +0,0 @@ -import modules from './modules'; -import { createStore } from 'redux'; - -export default function configureStore() { - const store = createStore( - modules, /* preloadedState, */ - (window as any).__REDUX_DEVTOOLS_EXTENSION__ && (window as any).__REDUX_DEVTOOLS_EXTENSION__() - ); - return store; -} \ No newline at end of file diff --git a/src/store/modules/counter.ts b/src/store/modules/counter.ts deleted file mode 100644 index 8a9ca95..0000000 --- a/src/store/modules/counter.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { createAction, handleActions } from 'redux-actions'; - -const INCREMENT = 'counter/INCREMENT'; -const DECREMENT = 'counter/DECREMENT'; - -export const actionCreators = { - increment: createAction(INCREMENT), - decrement: createAction(DECREMENT), -}; - -export interface CounterState { - value: number; -} - -const initialState: CounterState = { - value: 0 -}; - -export default handleActions( - { - [INCREMENT]: (state, action) => ({ value: state.value + 1 }), - [DECREMENT]: (state) => ({ value: state.value - 1 }), - }, - initialState -); diff --git a/src/store/modules/index.ts b/src/store/modules/index.ts deleted file mode 100644 index 88361bf..0000000 --- a/src/store/modules/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { combineReducers } from 'redux'; -import counter, { CounterState } from './counter'; -import todos, { TodosState } from './todos'; - -export default combineReducers({ - counter, - todos, -}); - -// 스토어의 상태 타입 정의 -export interface StoreState { - counter: CounterState; - todos: TodosState; -} \ No newline at end of file diff --git a/src/store/modules/todos.ts b/src/store/modules/todos.ts deleted file mode 100644 index 233beea..0000000 --- a/src/store/modules/todos.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { Record, List } from 'immutable'; -import { createAction, handleActions, Action } from 'redux-actions'; - -const CREATE = 'todos/CREATE'; -const REMOVE = 'todos/REMOVE'; -const TOGGLE = 'todos/TOGGLE'; -const CHANGE_INPUT = 'todos/CHANGE_INPUT'; - -type CreatePayload = string; -type RemovePayload = number; -type TogglePayload = number; -type ChangeInputPayload = string; - -/* type AnotherPayload = { - something: string; - like: number; - this: boolean -}; */ - -export const actionCreators = { - create: createAction(CREATE), - remove: createAction(REMOVE), - toggle: createAction(TOGGLE), - changeInput: createAction(CHANGE_INPUT) -}; - -const TodoItemRecord = Record({ - id: 0, - text: '', - done: false -}); - -interface TodoItemDataParams { - id?: number; - text?: string; - done?: boolean; -} - -export class TodoItemData extends TodoItemRecord { - static autoId = 0; - id: number; - text: string; - done: boolean; - constructor(params?: TodoItemDataParams) { - const id = TodoItemData.autoId; - if (params) { - super({ - ...params, - id, - }); - } else { - super({ id }); - } - TodoItemData.autoId = id + 1; - } -} - -const TodosStateRecord = Record({ - todoItems: List(), - input: '' -}); - -export class TodosState extends TodosStateRecord { - todoItems: List; - input: string; -} - -const initialState = new TodosState(); - -export default handleActions( - { - [CREATE]: (state, action: Action): TodosState => { - return state.withMutations( - s => { - s.set('input', '') - .update('todoItems', (todoItems: List) => todoItems.push( - new TodoItemData({ text: action.payload }) - )); - } - ); - }, - [REMOVE]: (state, action: Action): TodosState => { - return state.update( - 'todoItems', - (todoItems: List) => todoItems.filter( - t => t ? t.id !== action.payload : false - ) - ); - }, - [TOGGLE]: (state, action: Action): TodosState => { - const index = state.todoItems.findIndex(t => t ? t.id === action.payload : false); - return state.updateIn(['todoItems', index, 'done'], done => !done); - }, - [CHANGE_INPUT]: (state, action: Action): TodosState => { - return state.set('input', action.payload); - }, - }, - initialState -); \ No newline at end of file