Skip to content

Commit c76a49d

Browse files
fix(overmind): object prop delete, react hmr and sync events
1 parent 51f68dc commit c76a49d

File tree

14 files changed

+90
-26
lines changed

14 files changed

+90
-26
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"prismjs": "1.15.0",
3939
"react": "16.4.1",
4040
"react-dom": "16.4.1",
41+
"react-hot-loader": "^4.3.4",
4142
"styled-components": "3.3.3",
4243
"tslib": "1.9.3",
4344
"vue": "2.5.16",

packages/demos/todomvc/.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"plugins": ["../../../node_modules/react-hot-loader/babel"],
23
"presets": [
34
"../../../node_modules/@babel/preset-react",
45
"../../../node_modules/@babel/preset-typescript",

packages/demos/todomvc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"license": "MIT",
88
"repository": "git+https://github.com/cerebral/overmind.git",
99
"scripts": {
10-
"start": "webpack-dev-server --port 4000",
10+
"start": "webpack-dev-server --port 4000 --hot",
1111
"build": "webpack",
1212
"typecheck": "tsc --noEmit",
1313
"prepare": "npm run build",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export const addTodo: Action<React.FormEvent> = (action) =>
1616
.do(operations.preventEventDefault)
1717
.mutation(mutations.addTodo)
1818
.mutation(mutations.clearNewTodoTitle)
19+
.map(() => Promise.resolve())
20+
.map(() => Promise.resolve())
1921

2022
export const toggleCompleted: Action<Todo> = (action) =>
2123
action<Todo>().mutation(mutations.toggleCompleted)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Wrapper, Input, Button, Form } from './elements'
55
const AddTodo: React.SFC<Connect> = ({ app }) => (
66
<Wrapper>
77
{app.state.testCount(5)}
8+
{app.state.count}
89
<Form onSubmit={app.actions.addTodo}>
910
<Input
1011
placeholder="I need to..."

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { hot } from 'react-hot-loader'
12
import * as React from 'react'
23
import { Wrapper, InnerWrapper } from './elements'
34
import AddTodo from '../AddTodo'
@@ -12,4 +13,4 @@ const App: React.SFC = () => (
1213
</Wrapper>
1314
)
1415

15-
export default App
16+
export default hot(module)(App)

packages/node_modules/action-chain/src/ActionBase.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class ActionBase<Effects> {
113113
executionContextWithPath
114114
)
115115

116-
this.actionChain.emitAsync('operator:start', {
116+
this.actionChain.emit('operator:start', {
117117
type,
118118
name,
119119
path,
@@ -122,15 +122,15 @@ export class ActionBase<Effects> {
122122
const result = cb(effects, currentValue)
123123

124124
if (result instanceof Promise) {
125-
this.actionChain.emitAsync('operator:async', {
125+
this.actionChain.emit('operator:async', {
126126
type,
127127
name,
128128
path,
129129
isAsync: true,
130130
...thisExecution,
131131
})
132132
return result.then((promiseResult) => {
133-
this.actionChain.emitAsync('operator:end', {
133+
this.actionChain.emit('operator:end', {
134134
type,
135135
name,
136136
path,
@@ -142,7 +142,7 @@ export class ActionBase<Effects> {
142142
})
143143
}
144144

145-
this.actionChain.emitAsync('operator:end', {
145+
this.actionChain.emit('operator:end', {
146146
type,
147147
name,
148148
path,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export const performMutationsByMessageType: Mutation<Message> = (
9393
message
9494
) => {
9595
message.message.forEach((clientMessage) => {
96+
console.log(clientMessage)
9697
switch (clientMessage.type) {
9798
case 'init': {
9899
state.apps[message.port] = createApp({

packages/node_modules/overmind/src/Devtools.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ export default class Devtools {
8888
)
8989
}
9090
send(message: Message) {
91-
this.buffer.push(JSON.stringify(message))
92-
this.sendBuffer()
91+
setTimeout(() => {
92+
this.buffer.push(JSON.stringify(message))
93+
this.sendBuffer()
94+
})
9395
}
9496
private sendBuffer = debounce(function() {
9597
if (this.isConnected) {

0 commit comments

Comments
 (0)