Skip to content

Instantly share code, notes, and snippets.

View dispix's full-sized avatar

Octave Raimbault dispix

  • Datadog
  • Paris
View GitHub Profile
@dispix
dispix / CHANGELOG.md
Last active July 22, 2024 10:27
OAUTH2 Authentication and token management with redux-saga

Revision 5

  • Fix error parsing

Revision 4

  • Add missing yield in the login function

Revision 3

@dispix
dispix / PropertyType.ts
Last active October 18, 2021 15:15
Gives a strong typing to string accessors like `lodash/get`
// Extracts the type of a property deeply nested in an object
// Example: DeepProperty<'foo[0].bar', { foo: Array<{ bar: { baz: string } }> }> === { baz: string }
export type PropertyType<
TModel extends Record<string, any>,
TPath extends string
> = TPath extends keyof TModel
? TModel[TPath]
: TPath extends `${infer Key}.${infer RemainingPath}`
? Key extends keyof TModel
? PropertyType<TModel[Key], RemainingPath>
import { useRef, useEffect } from 'react'
function useUpdate(fn) {
const mounting = useRef(true)
useEffect(() => {
if (mounting.current) {
mounting.current = false
} else {
fn()
}
import { useEffect } from 'react'
function useUnmount(fn) {
useEffect(() => fn, [])
}
import { useEffect } from 'react'
function useMount(fn) {
useEffect(() => void fn(), [])
}
* Player class
* @class
* @classdesc Construct a new player with an independent redux store
*/
class Player {
/**
* Class constructor
*/
constructor() {
/**
@dispix
dispix / designer.html
Created April 27, 2015 12:57
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-item/paper-item.html">