Skip to content

Commit e36a8b1

Browse files
fix(overmind): fix typing of module operators, refactor todomvc
1 parent 3fc2ee3 commit e36a8b1

File tree

19 files changed

+65
-172
lines changed

19 files changed

+65
-172
lines changed

packages/demos/react-todomvc/src/app/actions.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/demos/react-todomvc/src/app/effects.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/demos/react-todomvc/src/app/index.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
1-
import Overmind from 'overmind'
2-
import createConnect from 'overmind-react'
3-
import * as effects from './effects'
4-
import * as actions from './actions'
5-
import * as state from './state'
1+
import { Overmind } from 'overmind'
2+
import { createConnect } from 'overmind-react'
63

74
const app = new Overmind({
8-
state,
9-
actions,
10-
effects,
5+
state: {
6+
todos: [],
7+
newTodoTitle: '',
8+
count: (state) => state.todos.length,
9+
},
10+
actions: {
11+
changeNewTodoTitle({ value: event, state }) {
12+
state.newTodoTitle = event.target.value
13+
},
14+
addTodo({ value: event, state }) {
15+
event.preventDefault()
16+
state.todos.unshift({
17+
title: state.newTodoTitle,
18+
completed: false,
19+
})
20+
},
21+
toggleCompleted({ value: todo }) {
22+
todo.completed = !todo.completed
23+
},
24+
},
1125
})
1226

1327
export const connect = createConnect(app)

packages/demos/react-todomvc/src/app/mutations.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/demos/react-todomvc/src/app/operations.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/demos/react-todomvc/src/app/state.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/demos/react-todomvc/src/components/Todos/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Todo from '../Todo'
55

66
const Todos = ({ app }) => (
77
<List>
8-
{app.state.todos.map((todo) => <Todo key={todo.id} todo={todo} />)}
8+
{app.state.todos.map((todo, index) => <Todo key={index} todo={todo} />)}
99
</List>
1010
)
1111

packages/demos/react-typescript-todomvc/src/app/actions.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,17 @@
11
import * as React from 'react'
2-
import {
3-
Action,
4-
pipe,
5-
Operator,
6-
map,
7-
mutate,
8-
when,
9-
run,
10-
wait,
11-
fork,
12-
debounce,
13-
filter,
14-
forEach,
15-
} from 'overmind'
2+
import { Action } from 'overmind'
163
import { Todo } from './state'
174

185
type ChangeEvent = React.ChangeEvent<HTMLInputElement>
196

207
let nextTodoId = 0
218

22-
export const changeNewTodoTitle: Operator<ChangeEvent, any> = pipe(
23-
map(({ value }) => value.target.value),
24-
mutate(({ state, value }) => (state.newTodoTitle = value)),
25-
map(() => ['foo', 'bar', 'baz']),
26-
forEach(run(() => {})),
27-
filter(() => true),
28-
debounce(200)
29-
)
30-
31-
/*
329
export const changeNewTodoTitle: Action<ChangeEvent> = ({
3310
value: event,
3411
state,
3512
}) => {
3613
state.newTodoTitle = event.target.value
3714
}
38-
*/
3915

4016
export const addTodo: Action = ({ state }) => {
4117
state.todos.unshift({

packages/demos/vue-todomvc/src/app/actions.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/demos/vue-todomvc/src/app/effects.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)