Skip to content

Instantly share code, notes, and snippets.

Avatar

Octave Raimbault dispix

  • Datadog
  • Paris
View GitHub Profile
View DeepProperty.ts
// Extracts the type of a property deeply nested in an object
// Example: DeepProperty<'foo[0].bar', { foo: Array<{ bar: { baz: string } }> }> === { baz: string }
type DeepProperty<Path, Target extends Record<string, any>> =
Path extends `${infer Key}.${infer RemainingPath}`
? Key extends keyof Target
? DeepProperty<RemainingPath, Target[Key]>
: Path extends `${infer Key}[${number}].${infer RemainingPath}`
? Key extends keyof Target
? Target[Key] extends any[]
? DeepProperty<RemainingPath, Target[Key][0]>
View useUpdate.js
import { useRef, useEffect } from 'react'
function useUpdate(fn) {
const mounting = useRef(true)
useEffect(() => {
if (mounting.current) {
mounting.current = false
} else {
fn()
}
View useUnmount.js
import { useEffect } from 'react'
function useUnmount(fn) {
useEffect(() => fn, [])
}
View useMount.js
import { useEffect } from 'react'
function useMount(fn) {
useEffect(() => void fn(), [])
}
@dispix
dispix / CHANGELOG.md
Last active Feb 15, 2021
OAUTH2 Authentication and token management with redux-saga
View CHANGELOG.md

Revision 5

  • Fix error parsing

Revision 4

  • Add missing yield in the login function

Revision 3

View class.jsx
* Player class
* @class
* @classdesc Construct a new player with an independent redux store
*/
class Player {
/**
* Class constructor
*/
constructor() {
/**
View designer.html
<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">