Skip to content

Instantly share code, notes, and snippets.

View christiannwamba's full-sized avatar

Christian Nwamba christiannwamba

  • AWS
  • Lagos, Nigeria
View GitHub Profile
// DEMO: Side effects with activities
// Look for beebing in the console
const initial = "idle";
const states = {
idle: {
on: {
ALARM: "alarming"
}
},
// DEMO: Calling events from other events
const echoMachine = Machine({
id: "echo",
initial: "listening",
states: {
listening: {
on: {
SPEAK: {
// Calls the ECHO action
// DEMO: Internal Transitions
const idleMachine = Machine(
{
id: "idle",
initial: "idle",
states: {
idle: {
entry: ["logEntry"],
exit: ["logExit"]
// DEMO: Hierarchical + Parallel States
const heatedStates = {
lowHeat: {
on: { TOGGLE_HEAT: 'highHeat' }
},
highHeat: {
on: { TOGGLE_HEAT: 'lowHeat' }
}
}
// 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:
version: '3.6'
services:
postgres:
image: postgres:12
restart: always
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgrespassword
graphql-engine:
const fetch = require("node-fetch")
const HASURA_OPERATION = `
mutation insertUser($username:String, $password:String) {
insert_user(objects: {username: $username, password: $password}) {
affected_rows
}
}
`;
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
}
}
/**
* Contructor Function to Class
*/
// BEFORE
function Team(name) {
this.name = name;
this.count = 14
}
@christiannwamba
christiannwamba / determine-changed-props.js
Created February 12, 2019 05:33 — forked from sorenlouv/determine-changed-props.js
Determine which props causes React components to re-render
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 => {