-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
3,228 additions
and
91 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<html lang="en" class="h-full"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="icon" href="/favicon.svg" type="image/svg+xml" /> | ||
<link rel="apple-touch-icon" href="/pwa-192x192.png" /> | ||
<link rel="mask-icon" href="/favicon.svg" color="#374151" /> | ||
<meta name="msapplication-TileColor" content="#374151" /> | ||
<meta name="theme-color" content="#374151" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<title>XState Choreography</title> | ||
</head> | ||
<body class="bg-gray-900"> | ||
<div id="app"></div> | ||
<body class="bg-gray-900 h-full"> | ||
<div id="app" class="h-full"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<template> | ||
<div> | ||
<h2 | ||
class=" | ||
sm:text-lg sm:leading-snug | ||
font-semibold | ||
tracking-wide | ||
uppercase | ||
text-gray-500 | ||
mb-3 | ||
" | ||
> | ||
Timestamp of Update: | ||
<span class="text-orange-600">{{ state.context.updatedAt }}</span> | ||
</h2> | ||
<h1 | ||
class=" | ||
text-4xl | ||
sm:text-6xl | ||
lg:text-7xl | ||
leading-none | ||
font-extrabold | ||
tracking-tight | ||
text-gray-300 | ||
mt-10 | ||
mb-8 | ||
sm:mt-14 sm:mb-10 | ||
" | ||
> | ||
You've toggled the browser | ||
<span class="text-orange-600">{{ state.context.counter }}</span> times. | ||
</h1> | ||
<p | ||
class=" | ||
max-w-4xl | ||
text-lg | ||
sm:text-2xl | ||
font-medium | ||
sm:leading-10 | ||
space-y-6 | ||
mb-6 | ||
text-gray-300 | ||
" | ||
> | ||
{{ state.context.msg }} | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { getActor } from '../machines/choreographer.machine' | ||
import { useActor } from '@xstate/vue' | ||
import { displayMachineId } from '../machines/display.machine' | ||
export default { | ||
setup() { | ||
const { state } = useActor(getActor(displayMachineId)) | ||
return { | ||
state, | ||
} | ||
}, | ||
} | ||
</script> |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { createMachine, assign, send } from 'xstate' | ||
import { displayMachineId } from './display.machine' | ||
import { choreographerMachine } from './choreographer.machine' | ||
|
||
export const counterMachineId = 'counter' | ||
|
||
export const counterMachine = createMachine( | ||
{ | ||
id: counterMachineId, | ||
context: { | ||
counter: null, | ||
}, | ||
on: { | ||
UPDATED_BROWSER_STATUS: { | ||
actions: ['updatedBrowserStatus', 'sendDisplayActor'], | ||
}, | ||
}, | ||
}, | ||
{ | ||
actions: { | ||
updatedBrowserStatus: assign({ | ||
counter: (ctx) => ctx.counter + 1, | ||
}), | ||
sendDisplayActor: send( | ||
(ctx) => ({ | ||
type: 'SEND_TO_ACTOR', | ||
actorId: displayMachineId, | ||
payload: { | ||
type: 'UPDATED_COUNTER', | ||
data: { | ||
count: ctx.counter, | ||
updatedAt: new Date(Date.now()).toISOString(), | ||
}, | ||
}, | ||
}), | ||
{ to: choreographerMachine }, | ||
), | ||
}, | ||
}, | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { createMachine, assign, send } from 'xstate' | ||
|
||
export const displayMachineId = 'display' | ||
|
||
export const displayMachine = createMachine( | ||
{ | ||
id: displayMachineId, | ||
context: { | ||
counter: 0, | ||
updatedAt: new Date(Date.now()).toISOString(), | ||
msg: null, | ||
}, | ||
on: { | ||
UPDATED_BROWSER_STATUS: { | ||
actions: ['storeUpdatedBrowserStatus'], | ||
}, | ||
UPDATED_COUNTER: { | ||
actions: ['storeUpdatedCount'], | ||
}, | ||
}, | ||
}, | ||
{ | ||
actions: { | ||
storeUpdatedBrowserStatus: assign({ | ||
msg: (_ctx, { data }) => { | ||
let msg = `The browser is currently online` | ||
|
||
if (!(data.online && data.visible && data.focused)) { | ||
msg = `The browser is offline or not currently focused` | ||
} | ||
|
||
return msg | ||
}, | ||
}), | ||
storeUpdatedCount: assign({ | ||
counter: (_, { data }) => data.count, | ||
updatedAt: (_, { data }) => data.updatedAt, | ||
}), | ||
}, | ||
}, | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
import { inspect } from '@xstate/inspect' | ||
import { router } from './router' | ||
|
||
// inspect({ | ||
// iframe: false, | ||
// }) | ||
|
||
createApp(App).use(router).mount('#app') | ||
createApp(App).mount('#app') |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.