Skip to content

Instantly share code, notes, and snippets.

stateDiagram-v2
    findAccount: Find Account
    moveOutAddress: Move Out Address
    meterAndScheduling: Meter & Scheduling
    finalBill: Final Bill
    reviewAndSubmit: Review & Submit

    [*]-->findAccount
    state findAccount {
type InferArguments<T> = T extends (...t: [...infer R]) => Promise<infer X>
? R
: never;
type InferResults<T> = T extends (...t: [...infer T]) => Promise<infer R>
? R
: never;
type AnyFn = (...args: any[]) => any;
@smoooty
smoooty / withErrorBoundary.tsx
Last active March 25, 2022 17:08
An error bound for react
import React from 'react';
import Logger from 'src/lib/Logger';
// Basically we try/catch WrappedComponent render so that we can render ErrorComponent if SSR error is caught
// Reference https://github.com/nayaknotnull/react-isomorphic-error-boundary
type ErrorComponentProps = {
componentName?: string;
error: Error;
};
const sleep = (ms: number) =>
new Promise((resolve, reject) =>
// Randomly resolve or reject to test Error
Math.random() < 0.5 ? setTimeout(resolve, ms) : setTimeout(reject, ms)
);
sleep(5000).then(() => ({ foo: 'bar' }));
@smoooty
smoooty / classname-union.ts
Last active March 5, 2021 16:53
Create a union type of strings from tailwind theme object
// Example js tailwind theme object
const theme = {
colors: {
red: {
default: '#1',
dark: '#2'
},
blue: {
default: '#3',
light: '#4'