This file contains hidden or 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 parseScannedData = | |
(context, event) => { | |
return (callback) => { | |
// This should be something that gets the json: | |
let { json } = {} // doSomethingAsync(); | |
let isValid = Array.isArray(json); | |
if (!isValid) { | |
callback({ type: 'SCAN_ERROR' }); | |
} else { |
This file contains hidden or 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 hidden or 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
import { Machine } from 'xstate'; | |
// This machine is completely decoupled from Ember | |
export const toggleMachine = Machine({ | |
id: 'toggle', | |
context: { | |
/* some data */ | |
}, | |
initial: 'inactive', | |
states: { |
This file contains hidden or 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
import Controller from '@ember/controller'; | |
function log(target) { | |
return class logWrapped extends target { | |
constructor(...args) { | |
console.log('Here', ...args); | |
super(...args); | |
} | |
} | |
} |
This file contains hidden or 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
export const CURRENT_STATE = Symbol('current state'); | |
export const STATE_PROPS = Symbol('state properties'); | |
export const MACHINE = Symbol('machine'); | |
export const LISTENERS = Symbol('listeners'); | |
export const CONFIG = Symbol('config'); | |
export const CONTEXT = Symbol('context'); |
This file contains hidden or 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
function createMachine() { | |
return Machine({ | |
id: 'example-form-manager', | |
type: 'parallel', | |
context: { | |
canSelectNone: true, | |
advancedProtocol: '', | |
ip4Address: '', | |
ip6Address: '' | |
}, |
This file contains hidden or 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 hidden or 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
//import { Machine, assign } from 'xstate'; | |
//import { isPresent } from '@ember/utils'; | |
function createMachine() { | |
return Machine({ | |
id: 'rule-group-data-manager', | |
initial: 'prefetching', | |
context: { | |
items: [], | |
clauses: null, |
This file contains hidden or 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
function createMachine() { | |
return Machine({ | |
id: 'example-form-manager', | |
type: 'parallel', | |
context: { | |
canSelectNone: true, | |
ip4Address: '', | |
ip6Address: '' | |
}, | |
states: { |
This file contains hidden or 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
import Component from '@glimmer/component'; | |
import { tracked } from '@glimmer/tracking'; | |
import { action } from '@ember/object'; | |
import { guidFor } from '@ember/object/internals'; | |
import { createMachine } from '../utils/-state-machine'; | |
const { interpret, assign } = XState; | |
export default class extends Component { | |
@tracked state; |