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
// DEMO: Side effects with activities | |
// Look for beebing in the console | |
const initial = "idle"; | |
const states = { | |
idle: { | |
on: { | |
ALARM: "alarming" | |
} | |
}, |
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
// DEMO: Calling events from other events | |
const echoMachine = Machine({ | |
id: "echo", | |
initial: "listening", | |
states: { | |
listening: { | |
on: { | |
SPEAK: { | |
// Calls the ECHO action |
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
// DEMO: Internal Transitions | |
const idleMachine = Machine( | |
{ | |
id: "idle", | |
initial: "idle", | |
states: { | |
idle: { | |
entry: ["logEntry"], | |
exit: ["logExit"] |
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
// DEMO: Hierarchical + Parallel States | |
const heatedStates = { | |
lowHeat: { | |
on: { TOGGLE_HEAT: 'highHeat' } | |
}, | |
highHeat: { | |
on: { TOGGLE_HEAT: 'lowHeat' } | |
} | |
} |
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
// DEMO: General demo with light bulp | |
// - Context | |
// - Actions | |
// -- Transitions | |
// -- Exit and Entry | |
// - States | |
// - Assign | |
// - Services https://codesandbox.io/s/xstate--bulb-demo-gkqrx?file=/src/index.js | |
// Available variables: |
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
version: '3.6' | |
services: | |
postgres: | |
image: postgres:12 | |
restart: always | |
volumes: | |
- db_data:/var/lib/postgresql/data | |
environment: | |
POSTGRES_PASSWORD: postgrespassword | |
graphql-engine: |
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 fetch = require("node-fetch") | |
const HASURA_OPERATION = ` | |
mutation insertUser($username:String, $password:String) { | |
insert_user(objects: {username: $username, password: $password}) { | |
affected_rows | |
} | |
} | |
`; |
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 fetch = require('node-fetch'); | |
const bcrypt = require('bcrypt'); | |
module.exports = async function(context, req) { | |
const HASURA_OPERATION = ` | |
mutation insertUser($username:String, $password:String) { | |
insert_user(objects: {username: $username, password: $password}) { | |
affected_rows | |
} | |
} |
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
/** | |
* Contructor Function to Class | |
*/ | |
// BEFORE | |
function Team(name) { | |
this.name = name; | |
this.count = 14 | |
} |
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
import React, { Component } from 'react'; | |
export default function withPropsChecker(WrappedComponent) { | |
return class PropsChecker extends Component { | |
componentWillReceiveProps(nextProps) { | |
Object.keys(nextProps) | |
.filter(key => { | |
return nextProps[key] !== this.props[key]; | |
}) | |
.map(key => { |