Skip to content

Commit da0e63d

Browse files
refactor(overmind): change connect props to app namespace
1 parent 3f18d47 commit da0e63d

File tree

18 files changed

+96
-86
lines changed

18 files changed

+96
-86
lines changed

package-lock.json

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/demos/todomvc/src/app/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ const app = new App(
2020

2121
export type Connect = TConnect<typeof app.state, typeof app.actions>
2222

23-
export const connect = app.connect.bind(app)
23+
export const connect = app.connect
2424

2525
export default app

packages/demos/todomvc/src/components/AddTodo/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import * as React from 'react'
22
import { connect, Connect } from '../../app'
33
import { Wrapper, Input, Button, Form } from './elements'
44

5-
const AddTodo: React.SFC<Connect> = ({ appState, actions }) => (
5+
const AddTodo: React.SFC<Connect> = ({ app }) => (
66
<Wrapper>
7-
<Form onSubmit={actions.addTodo}>
7+
<Form onSubmit={app.actions.addTodo}>
88
<Input
99
placeholder="I need to..."
10-
value={appState.newTodoTitle}
11-
onChange={actions.changeNewTodoTitle}
10+
value={app.state.newTodoTitle}
11+
onChange={app.actions.changeNewTodoTitle}
1212
/>
13-
<Button disabled={!appState.newTodoTitle}>add</Button>
13+
<Button disabled={!app.state.newTodoTitle}>add</Button>
1414
</Form>
1515
</Wrapper>
1616
)
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react'
2-
import { connect, Connect } from '../../app'
32
import { Wrapper, InnerWrapper } from './elements'
43
import AddTodo from '../AddTodo'
54
import Todos from '../Todos'
65

7-
const App: React.SFC<Connect> = ({ appState, actions }) => (
6+
const App: React.SFC = () => (
87
<Wrapper>
98
<InnerWrapper>
109
<AddTodo />
@@ -13,4 +12,4 @@ const App: React.SFC<Connect> = ({ appState, actions }) => (
1312
</Wrapper>
1413
)
1514

16-
export default connect(App)
15+
export default App

packages/demos/todomvc/src/components/Todo/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ type Props = {
77
todo: Todo
88
} & Connect
99

10-
const Todo: React.SFC<Props> = ({ todo, actions }) => (
11-
<Item onClick={() => actions.toggleCompleted(todo)}>
10+
const Todo: React.SFC<Props> = ({ todo, app }) => (
11+
<Item onClick={() => app.actions.toggleCompleted(todo)}>
1212
<Completed completed={todo.completed}></Completed> {todo.title}
1313
</Item>
1414
)

packages/demos/todomvc/src/components/Todos/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { connect, Connect } from '../../app'
33
import { List } from './elements'
44
import Todo from '../Todo'
55

6-
const Todos: React.SFC<Connect> = ({ appState }) => (
6+
const Todos: React.SFC<Connect> = ({ app }) => (
77
<List>
8-
{appState.todos.map(
8+
{app.state.todos.map(
99
(todo, index) =>
1010
console.log('todo ID', todo.id) || <Todo key={todo.id} todo={todo} />
1111
)}

packages/node_modules/overmind-devtools/src/app/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ const app = new App({
1515

1616
export type Connect = TConnect<typeof app.state, typeof app.actions>
1717

18-
export const connect = app.connect.bind(app)
18+
export const connect = app.connect
1919

2020
export default app

packages/node_modules/overmind-devtools/src/components/Components/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Table, { Row, Cell } from '../common/Table'
55
import Pill from '../common/Pill'
66
import { Wrapper, Panels, Panel } from './elements'
77

8-
const Components: React.SFC<Connect> = ({ appState }) => (
8+
const Components: React.SFC<Connect> = ({ app }) => (
99
<Wrapper>
1010
<div>
1111
<Panels>
@@ -14,29 +14,29 @@ const Components: React.SFC<Connect> = ({ appState }) => (
1414
connected
1515
</Text>
1616
<Text variant="header" dense>
17-
{appState.componentsMounted.length}
17+
{app.state.componentsMounted.length}
1818
</Text>
1919
</Panel>
2020
<Panel>
2121
<Text variant="label" dense>
2222
update count
2323
</Text>
2424
<Text variant="header" dense>
25-
{appState.componentsUpdateCount}
25+
{app.state.componentsUpdateCount}
2626
</Text>
2727
</Panel>
2828
<Panel>
2929
<Text variant="label" dense>
3030
paths watched
3131
</Text>
3232
<Text variant="header" dense>
33-
{appState.componentsStatePathCount}
33+
{app.state.componentsStatePathCount}
3434
</Text>
3535
</Panel>
3636
</Panels>
3737
</div>
3838
<Table headers={['name', 'updates', 'values']}>
39-
{appState.componentsMounted.map((component) => {
39+
{app.state.componentsMounted.map((component) => {
4040
return (
4141
<Row key={component.id}>
4242
<Cell>{component.name}</Cell>

packages/node_modules/overmind-devtools/src/components/Console/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Wrapper } from './elements'
55

66
class Console extends React.Component<Connect> {
77
render() {
8-
const { appState } = this.props
9-
const messagesReversed = appState.currentApp.messages.slice().reverse()
8+
const { app } = this.props
9+
const messagesReversed = app.state.currentApp.messages.slice().reverse()
1010

1111
return (
1212
<Wrapper>

packages/node_modules/overmind-devtools/src/components/Devtools/index.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Workspace from '../Workspace'
88

99
class Devtools extends React.Component<Connect> {
1010
componentDidMount() {
11-
this.props.actions.loadDevtools()
11+
this.props.app.actions.loadDevtools()
1212
}
1313
/*
1414
storeCurrentApps(apps) {
@@ -63,10 +63,10 @@ class Devtools extends React.Component<Connect> {
6363
*/
6464
onPortSubmit = (event: React.FormEvent) => {
6565
event.preventDefault()
66-
this.props.actions.addPort()
66+
this.props.app.actions.addPort()
6767
}
6868
renderAddPort() {
69-
const { appState, actions } = this.props
69+
const { app } = this.props
7070
return (
7171
<Wrapper>
7272
<Container>
@@ -79,12 +79,16 @@ class Devtools extends React.Component<Connect> {
7979
</Text>
8080
<form onSubmit={this.onPortSubmit}>
8181
<Input
82-
value={appState.newPortValue}
83-
onChange={actions.changeNewPortValue}
82+
value={app.state.newPortValue}
83+
onChange={app.actions.changeNewPortValue}
8484
length={4}
8585
placeholder="port..."
8686
addon={
87-
<Button type="submit" disabled={!appState.newPortValue} primary>
87+
<Button
88+
type="submit"
89+
disabled={!app.state.newPortValue}
90+
primary
91+
>
8892
Add
8993
</Button>
9094
}
@@ -95,17 +99,17 @@ class Devtools extends React.Component<Connect> {
9599
)
96100
}
97101
render() {
98-
const { appState } = this.props
102+
const { app } = this.props
99103

100-
if (appState.isLoading) {
104+
if (app.state.isLoading) {
101105
return (
102106
<Wrapper>
103107
<h1>loading...</h1>
104108
</Wrapper>
105109
)
106110
}
107111

108-
if (Object.keys(appState.apps).length) {
112+
if (Object.keys(app.state.apps).length) {
109113
return <Workspace />
110114
}
111115

0 commit comments

Comments
 (0)