Skip to content

Instantly share code, notes, and snippets.

View CodingDive's full-sized avatar
🎯
Focusing

Mikey Stengel CodingDive

🎯
Focusing
View GitHub Profile
@CodingDive
CodingDive / routes.js
Last active September 8, 2018 01:51
Adonis routes.js helper to use a component based folder structure
/**
* 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/
@CodingDive
CodingDive / controllers.application.js
Created February 19, 2019 12:24
Computed Property on Array
import Ember from 'ember';
import { inject as service } from '@ember/service';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
myService: service(),
});
@CodingDive
CodingDive / controllers.application.js
Created February 19, 2019 15:57
Ember Light Table hidden reproduction
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@CodingDive
CodingDive / machine.js
Last active December 4, 2019 15:08
Generated by XState Viz: https://xstate.js.org/viz
const lightSwitchMachine = Machine({
id: 'lightSwitch',
initial: 'inactive',
states: {
inactive: {
on: {
TOGGLE: 'active'
}
},
active: {
@CodingDive
CodingDive / machine.js
Last active December 8, 2019 21:24
Generated by XState Viz: https://xstate.js.org/viz
const videoChatMachine = Machine({
id: 'videoChat',
initial: 'audioDisabledVideoDisabled',
states: {
audioDisabledVideoDisabled: {
on: {
ENABLE_VIDEO: 'audioDisabledVideoEnabled',
ENABLE_AUDIO: 'audioEnabledVideoDisabled'
}
},
@CodingDive
CodingDive / machine.js
Last active September 18, 2019 15:43
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@CodingDive
CodingDive / machine.js
Created September 18, 2019 17:27
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@CodingDive
CodingDive / rejectedPromiseInXStateMachineExample.ts
Last active November 19, 2019 21:50
Promise error and notification handling in xstate + react
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);
},
},
}),
@CodingDive
CodingDive / machine.js
Created December 14, 2019 16:50
Generated by XState Viz: https://xstate.js.org/viz
const thermostatMachine = Machine({
id: 'thermostat',
initial: 'inactive',
context: {
temperature: 20,
},
states: {
inactive: {
on: {
POWER_TOGGLE: 'active'
@CodingDive
CodingDive / machine.js
Last active December 16, 2019 20:45
Generated by XState Viz: https://xstate.js.org/viz
const thermostatMachine = Machine({
id: 'thermostat',
initial: 'inactive',
context: {
temperature: 20,
},
states: {
inactive: {
on: {
POWER_TOGGLE: 'active'