Created
October 29, 2020 14:48
-
-
Save mikebevz/dd3b314da1c10649fca445420508bab2 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const fetchMachine = Machine({ | |
id: 'softPhoneSM', | |
context: { | |
/* some data */ | |
id: '123' | |
}, | |
initial: 'wsNotConnected', | |
states: { | |
wsNotConnected: { | |
on: { CONNECT: 'wsConnecting' }, | |
}, | |
wsConnecting: { | |
on: { | |
CONNECTED: 'wsConnected', | |
ERROR: 'wsConnectionFailed' | |
}, | |
}, | |
wsConnectionFailed: { | |
on: { | |
CONNECT: 'wsConnecting' | |
} | |
}, | |
wsConnected: { | |
initial: 'resting', | |
on: { | |
CALL: 'wsConnected.ringing', | |
INCOMING_CALL: 'wsConnected.incomingCall', | |
DISCONNECTED: 'wsNotConnected' | |
}, | |
states: { | |
resting: { | |
id: 'root_resting', | |
on: { CALL: 'ringing' }, | |
}, | |
ringing: { | |
on: { | |
ANSWERED: 'callInProgress', | |
CANCEL: 'cancelled', | |
REJECTED: 'callFailed' | |
}, | |
}, | |
callFailed: { | |
on: { | |
PROCEED: 'resting' | |
} | |
}, | |
incomingCall: { | |
on: { | |
ANSWER: 'callInProgress', | |
REJECT: 'incomingCallRejected' | |
} | |
}, | |
incomingCallRejected: { | |
on: { | |
PROCEED: 'resting' | |
} | |
}, | |
cancelled: { | |
id: 'root_cancelled', | |
on: { | |
PROCEED: 'resting' | |
} | |
}, | |
callInProgress: { | |
initial: 'inProgress', | |
on: { | |
HANGUP: 'resting' , | |
}, | |
states: { | |
held: { | |
on: { | |
UNHOLD: 'inProgress', | |
CANCEL: '#root_cancelled' | |
} | |
}, | |
inProgress: { | |
initial: 'notMuted', | |
on: { | |
HANGUP: '#root_resting', | |
HOLD: 'held' | |
}, | |
states: { | |
notMuted: { | |
on: { | |
MUTE: 'muted' | |
} | |
} , | |
muted: { | |
on: { | |
ONMUTE: 'notMuted' | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment