Skip to content

Commit

Permalink
feat: Do를 사용하는 예제인 CoutDo 구현 (CC-88)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunkkkk committed Jul 26, 2024
1 parent 76e3b45 commit d3525a9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Caecae/src/Shared/Hyundux/Example_Counter/CountDo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { createState } from "../State";
import { DoAction } from "../Actions";
import State from "../State";
import { makePayLoad } from "../Util/StoreUtil";

const Do_NAME = "Count";

// state type
interface CountPayLoad {
count: number;
text: string;
}

const initCountState = createState<CountPayLoad>(Do_NAME, {
count: 0,
text: "helloWorld",
});

// actions
const doAction = {
countUp: (): DoAction<CountPayLoad> => {
return {
type: Do_NAME,
doing: (state: State<CountPayLoad>): State<CountPayLoad> => {
return makePayLoad(state, { count: state.payload.count + 1 });
},
};
},
};

export { doAction, initCountState };

0 comments on commit d3525a9

Please sign in to comment.