This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
// build123d CodeCAD speedmodeling snippet by Jern | |
// | |
// This was specifically designed for use with TooTallToby's modeling challenges, but applicable for | |
// all CodeCAD modeling, but customize as desired for your own needs. This provides: | |
// 1. A file template that reduces the time necessary to "just start coding/modeling" | |
// 2. Shortcuts like "?ebds + TAB" that creates a BuildSketch + extrude block | |
// | |
// recommended to bind "Snippets: Fill file with Snippet" to e.g. CTRL + ALT + N | |
// recommended to bind "Jupyter: Restart Kernel" to e.g. CTRL + ALT + / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Consistent version of `useMutableSource`, Inspired by https://github.com/pmndrs/valtio/blob/master/src/useMutableSource.ts | |
import { useEffect, useRef, useState } from 'react'; | |
const TARGET = Symbol('target'); | |
const GET_VERSION = Symbol('getVersion'); | |
export type Source<TargetType extends any, VersionType extends any> = { | |
[TARGET]: TargetType; | |
[GET_VERSION]: (target: TargetType) => VersionType; | |
}; |