This file contains hidden or 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
import invariant from "tiny-invariant"; | |
class AmalgoBox extends HTMLElement { | |
get input() { | |
return this.querySelector("input") as HTMLInputElement; | |
} | |
get button() { | |
return this.querySelector("button") as HTMLButtonElement; | |
} |
This file contains hidden or 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
// A very naive implementation of React's use() hook you can copy and paste into your app today | |
// to use with solutions such as remix's experimental `defer()` feature. | |
function use<T>(useable: Promise<T> | T) { | |
if (typeof useable != "object" || !useable || !("then" in useable)) { | |
return useable; | |
} | |
let promise = useable as Promise<T> & { _data?: T; _error?: unknown }; | |
if ("_data" in promise) { |
OlderNewer