Skip to content

Commit

Permalink
feat(overmind): change to send instead of transition
Browse files Browse the repository at this point in the history
  • Loading branch information
christianalfoni committed Oct 9, 2020
1 parent 944886c commit b74acc9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/node_modules/overmind/src/statemachine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Statemachine', () => {
current: 'FOO'
})
const transition: Action = ({ state }) => {
state.transition('TOGGLE')
state.send('TOGGLE')
}

const config = {
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('Statemachine', () => {
current: 'FOO'
})
const transition: Action = ({ state }) => {
state.transition('TOGGLE')
state.send('TOGGLE')
}

const config = {
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('Statemachine', () => {
})

const transition: Action = ({ state }) => {
state.transition('TOGGLE')
state.send('TOGGLE')
}

const config = {
Expand Down
5 changes: 2 additions & 3 deletions packages/node_modules/overmind/src/statemachine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import isPlainObject from 'is-plain-obj'
import { PATH, VALUE } from 'proxy-state-tree'

import { deepCopy } from './utils'
Expand All @@ -24,7 +23,7 @@ export interface MachineMethods<States extends TState, Events extends TEvents> {
matches<T extends States["current"]>(
current: T,
): Statemachine<States extends { current: T} ? States : never, Events> | undefined
transition<T extends Events["type"]>(
send<T extends Events["type"]>(
...args: Events extends { type: T, data: any } ? [T, Events["data"]] : [T]
): Statemachine<States extends { current: T} ? States : never, Events> | undefined
}
Expand Down Expand Up @@ -59,7 +58,7 @@ export class StateMachine<State extends TState, Events extends TEvents> {
this[TRANSITIONS] = transitions
Object.assign(this, state)
}
transition(type, data) {
send(type, data) {
if (this[VALUE][IS_DISPOSED]) {
if (process.env.NODE_ENV === 'development') {
console.warn(`Overmind - The statemachine at "${this[PATH]}" has been disposed, but you tried to transition on it`)
Expand Down

0 comments on commit b74acc9

Please sign in to comment.