Skip to content

Instantly share code, notes, and snippets.

import { setup, assign, createActor, enqueueActions } from 'xstate';
// go back and do a git commit from original data
// input is typed
// context is typed
// fix errors below
// try with writing in the dom stuff...
// done: keep searching strongly typed in discord
// how else can i try the autocomplete for event properties
// todo: it seems that it errors if input isnt given, [confirm by removing input and putting another valid option in that space], but there should be a way to have optional input...
// todo: ask stately what the schema is doing, do i need it?

Frameworks like React require that when you change the contents of an array or object you change its reference. Or push another way that you don't change arrays but instead create new arrays with updated values (i.e. immutability).

There are older array methods that are incompatible with immutability because they alter the array in place and don't change the array reference. These are mutable (or destructive) methods.

Shown below are replacements for the array destructive methods (e.g. push, pop, splice, sort, etc.) that will create new array references with the updated data.

Solutions are provided using the spread operator and also the newer "change array by copy" methods (toSpliced, toSorted, toReversed and with).

Setting Value At Index

@airandopal
airandopal / generatePropertyControls.ts
Created July 15, 2023 23:17 — forked from addisonschultz/generatePropertyControls.ts
Reuse Property Controls easily in Framer X
import { ControlType, PropertyControls } from "framer";
export function generatePropertyControls(
options: {
hidden?: (props: any) => boolean;
omittedProperties?: string[];
} = {}
): PropertyControls {
const properties: PropertyControls = {
// Property Controls go here
// const { assign, interpret, Machine } = require('xstate')
const multiColoredBulbMachine = Machine(
{
id: 'multiColoredBulb',
initial: 'unlit',
context: {
color: '#fff',
},
states: {
@airandopal
airandopal / machine.js
Last active May 3, 2021 01:27
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@airandopal
airandopal / machine.js
Last active May 19, 2020 06:44
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@airandopal
airandopal / On2Air: Default Values Script
Created April 14, 2020 03:33 — forked from dev-on2air/On2Air: Default Values Script
Script for setting default values in Airtable
/*****
* Title: Manage & Run Default Values
* License: MIT
* Author: Openside (Team behind On2Air products and BuiltOnAir community)
* Sites:
* https://openside.com - Openside Consulting Services
* https://openside.com/#products - On2Air Products
* https://builtonair.com - All things Airtable Community
*
* Reach out for all your Airtable needs
@airandopal
airandopal / machine.js
Last active November 19, 2019 03:35
Generated by XState Viz: https://xstate.js.org/viz
// todo: move these to guards object in machine
const isError = (context, event) => {
return context.isError;
};
const isNoError = (context, event) => {
return context.noError;
};
const isComplete = (context, event) => {
return context.isComplete;
};
@airandopal
airandopal / machine.js
Last active November 19, 2019 03:35
Generated by XState Viz: https://xstate.js.org/viz
// todo: move these to guards object in machine
const isError = (context, event) => {
return context.isError;
};
const isNoError = (context, event) => {
return context.noError;
};
const isComplete = (context, event) => {
return context.isComplete;
};
@airandopal
airandopal / machine.js
Last active November 19, 2019 03:33
Generated by XState Viz: https://xstate.js.org/viz
// this one has stripe error types - https://xstate.js.org/viz/?gist=239a9b108fc7a71700b37726e7976572
// main from this - https://xstate.js.org/viz/?gist=bcd933870edb3507002bd72524c83c11
/// NEW ISh
// todo: move these to guards object in machine
const isError = (context, event) => {
return context.isError;
};