Skip to content

Instantly share code, notes, and snippets.

View olavoasantos's full-sized avatar

Olavo Amorim Santos olavoasantos

  • Shopify
  • Winnipeg, MB
View GitHub Profile
export type MaterialIcons =
| '10k'
| '10mp'
| '11mp'
| '12mp'
| '13mp'
| '14mp'
| '15mp'
| '16mp'
| '17mp'
@olavoasantos
olavoasantos / Board.ts
Created April 17, 2020 21:29
Tic Tac Toe implementation
export class Board {
public size: number;
protected board: (null | 'o' | 'x')[];
constructor(size: number = 3) {
this.size = size;
this.board = Array(size * size).fill(null);
}
@olavoasantos
olavoasantos / useAsync.ts
Created November 15, 2019 22:26
Skipable async function hook
/**
* useAsync<T>(asyncFunc, options)
* @arg asyncFunc: (variables: Options) => Promise<T> Asynchronous function to be called
* @arg options: Options: { Options. The hook will only call
* skip: boolean; the asyncFunc when `skip=false`.
* variables: { [key: string]: any } `variables` will be passed to the
* } function whe it's called.
*
* @returns [ executeFunction, asyncState ]
* ---
@olavoasantos
olavoasantos / useLazyAsync.ts
Created November 15, 2019 22:22
Lazily run async functions with React hooks
/**
* useLazyAsync<T>(asyncFunc, options)
* @arg asyncFunc: (variables: Options) => Promise<T> Asynchronous function to be called
* @arg options: Options: {variables: { [key: string]: any }} Options. `variables` will be passed
* to the function whe it's called
* @returns [ executeFunction, asyncState ]
* ---
* Usage:
* const [execute, state] = useLazyAsync(
* ({ name }) => new Promise((res, rej) => res(`Hello, ${name}`)),
import { omit } from 'lodash';
const filter = () => true;
const getUndefined = () => {};
const getType = (action) => action.type;
const identity = (x) => x;
const createSentryMiddleware = (Sentry, options = {}) => {
const {
actionTransformer = identity,