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
| /** | |
| * This is a gist with small route template helpers for people using a component structure as seen below. | |
| * Inside your start/routes.js file | |
| * Example: | |
| * ``` | |
| * require(routeTemplate("Authentication")); | |
| * require(nestedRouteTemplate("Payment", "PayPal")); | |
| * ``` | |
| app/ | |
| ├── Components/ |
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 Ember from 'ember'; | |
| import { inject as service } from '@ember/service'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle', | |
| myService: service(), | |
| }); |
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 Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle' | |
| }); |
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 lightSwitchMachine = Machine({ | |
| id: 'lightSwitch', | |
| initial: 'inactive', | |
| states: { | |
| inactive: { | |
| on: { | |
| TOGGLE: 'active' | |
| } | |
| }, | |
| active: { |
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 videoChatMachine = Machine({ | |
| id: 'videoChat', | |
| initial: 'audioDisabledVideoDisabled', | |
| states: { | |
| audioDisabledVideoDisabled: { | |
| on: { | |
| ENABLE_VIDEO: 'audioDisabledVideoEnabled', | |
| ENABLE_AUDIO: 'audioEnabledVideoDisabled' | |
| } | |
| }, |
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
| // 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 { useMachine } from '@xstate/react' | |
| const { sendNotification } = useContext(notificationContext) | |
| const [state, send] = useMachine( | |
| fetchMachine.withConfig({ | |
| actions: { | |
| sendErrorNotification: (ctx, e) => { | |
| sendNotification(NOTIFICATION_SEVERITY.ERROR, e.data.message); | |
| }, | |
| }, | |
| }), |
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 thermostatMachine = Machine({ | |
| id: 'thermostat', | |
| initial: 'inactive', | |
| context: { | |
| temperature: 20, | |
| }, | |
| states: { | |
| inactive: { | |
| on: { | |
| POWER_TOGGLE: 'active' |
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 thermostatMachine = Machine({ | |
| id: 'thermostat', | |
| initial: 'inactive', | |
| context: { | |
| temperature: 20, | |
| }, | |
| states: { | |
| inactive: { | |
| on: { | |
| POWER_TOGGLE: 'active' |
OlderNewer