Skip to content

Instantly share code, notes, and snippets.

@hnordt
hnordt / machine.js
Last active September 20, 2019 21:57
Generated by XState Viz: https://xstate.js.org/viz
let widgetSettingsMachine = Machine({
id: 'widgetSettings',
context: {},
type: "parallel",
states: {
general: {
on: {
CHANGE_NAME: {
actions: "updateName"
},
@hnordt
hnordt / machine.js
Last active September 13, 2019 21:38
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@hnordt
hnordt / machine.js
Created July 29, 2019 22:53
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@hnordt
hnordt / machine.js
Last active July 20, 2019 04:49
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: "approvals",
context: {
page: 0,
results: [],
selectedIds: {},
error: null
},
type: "parallel",
states: {
@hnordt
hnordt / machine.js
Last active July 20, 2019 01:14
Generated by XState Viz: https://xstate.js.org/viz
let approvalsMachine = Machine(
{
id: "approvals",
context: {
dateStart: "",
dateEnd: "",
page: 0,
results: [],
items: {},
error: null
@hnordt
hnordt / machine.js
Created July 15, 2019 23:26
Generated by [XState Viz](https://xstate.js.org/viz)
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
function Col({
as = "div",
justifyContent,
alignItems,
flex,
children
}) {
return createElement(as, {
className: css({
display: "flex",
function Spacer({ size }) {
return (
<span
className={css({
display: "block",
width: `var(--spacing-${size})`,
height: `var(--spacing-${size})`
})}
aria-hidden
/>
// Good
let { parameters, customParameters } = connection;
let firstName = customParameters.get("FirstName");
let lastName = customParameters.get("LastName");
// Lets say we now need to pass eventId.
// One could easily add it inside caller as it
// already has multiple props, and things are a bit
// This code handles complexity higher in the tree.
//
// It makes higher-level components more complicated, but the whole
// rendering logic is contained in a single place, which might
// help long-term maintenance.
function Call() {
let { state, send } = useContext(TelecomContext);
let { caller } = state.context;