Skip to content

Commit

Permalink
fix(overmind): revert the new async serialize and parse strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
christianalfoni committed Sep 1, 2020
1 parent ffe9594 commit f5870ec
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { parse } from 'non-blocking-json'

import { AppMessage } from './overmind/types'

type Message = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { createApp, getActionId, isValidJson } from './utils'

export const onMessage: Operator<Message> = pipe(
o.ensureCurrentApp(),
o.stringifyMessage(),
o.filterStringified(),
o.ensureApp(),
o.addClientMessage(),
o.getMessage(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { parse, Payload } from 'non-blocking-json'
import { Operator, filter, fork, map, mutate } from 'overmind'

import {
Expand Down Expand Up @@ -106,18 +105,6 @@ export const addClientMessage: () => Operator<Message> = () =>
state.apps[message.appName].messages.unshift(message.message)
})

export const stringifyMessage: () => Operator<Message> = () =>
map((_, message) => {
const result = parse(message.message as unknown as Payload)

return result ? {
...message,
message: result
} : undefined
})

export const filterStringified: () => Operator<Message> = () =>
filter((_, message) => Boolean(message))

export const addComponent: () => Operator<AddComponentMessage> = () =>
mutate(({ state }, message) => {
Expand Down
8 changes: 2 additions & 6 deletions packages/node_modules/overmind/src/Devtools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { stringify } from 'non-blocking-json'
import { SERIALIZE } from './rehydrate'

export type Message = {
Expand Down Expand Up @@ -83,11 +82,8 @@ export class Devtools {
const unsafeClassNames = this.unsafeClassNames
const circularReferenceCache = this.circularReferenceCache

stringify(
this.sendMessage(JSON.stringify(
message,
(payload) => {
this.sendMessage(payload)
},
function (_, value) {
if (typeof value === 'function') {
return '[Function]'
Expand Down Expand Up @@ -140,7 +136,7 @@ export class Devtools {

return value
}
)
))
circularReferenceCache.length = 0
}

Expand Down

0 comments on commit f5870ec

Please sign in to comment.