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
type track = { | |
name: string, | |
artist: string, | |
}; | |
let tracks = [| | |
{artist: "Kromestar", name: "007"}, | |
{artist: "Kromestar", name: "008"}, | |
{artist: "Kromestar", name: "009"}, | |
{artist: "Kromestar", name: "010"}, | |
{artist: "Kromestar", name: "011"}, |
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
type progress = | |
| Stopped | |
| Playing | |
| Rewinding | |
| FastForwarding | |
| Paused; | |
type playerState = { | |
status: progress, | |
activeTrackIndex: option(int), | |
}; |
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
const fetchQuizData = () => | |
fetch( | |
`https://opentdb.com/api.php?amount=10&difficulty=hard&type=boolean`, | |
).then(response => response.json()) | |
const normalizeQuizData = (data) => | |
data.reduce( | |
(acc, obj) => [ | |
...acc, | |
{ |
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 |
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 |
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
const optimisticInputMachine = initial => Machine({ | |
id: 'optimisticInput', | |
initial: 'idle', | |
context: { | |
value: initial, | |
savedValue: initial, | |
}, | |
states: { | |
idle: { | |
on: { |
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
const optimisticInputMachine = initial => Machine({ | |
id: 'optimisticInput', | |
initial: 'idle', | |
context: { | |
value: initial, | |
savedValue: initial, | |
}, | |
states: { | |
idle: { | |
on: { |
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 |
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
const assignField = (name) => assign({ [name]: (ctx, event) => event.payload }); | |
const initialContext = { | |
agreeToTerms: undefined, | |
}; | |
const quoteAcceptionMachine = Machine({ | |
id: 'quoteAcception', | |
initial: 'loading', | |
context: initialContext, | |
meta: { |
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 |
OlderNewer