Skip to content

Instantly share code, notes, and snippets.

View beorn's full-sized avatar

Bjørn Stabell beorn

View GitHub Profile
@beorn
beorn / brainstorming12.tsx
Last active November 12, 2024 21:04
Another experiment using (state) => instead of this
import React from "react"
/** Base class for reactive values that can notify subscribers of changes */
class Observable<T> {
protected _value: T
protected subscribers = new Set<() => void>()
/** Tracks dependencies during computed property evaluation */
static currDeps: Set<Observable<any>> | null = null
constructor(value: T) {
@beorn
beorn / brainstorming11.tsx
Last active November 11, 2024 23:52
Another test of reactive state
// NOTE: I did use Cursor/LLMs to help write this
import React from "react"
/** Base class for reactive values that can notify subscribers of changes */
class Observable<T> {
protected _value: T
protected subscribers = new Set<() => void>()
/** Tracks dependencies during computed property evaluation */
static currDeps: Set<Observable<any>> | null = null
@beorn
beorn / brainstorming-state.tsx
Last active November 11, 2024 07:18
Brainstorming different kinds of state mgmt APIs
// NOTE: I did use ChatGPT for help fleshing this out
import React from "react"
// Global variable to track current computation for dependency tracking
let currentComputation: ComputedObservable<any> | null = null
// Observable class to handle state changes and subscriptions
class Observable<T> {
#value: T
### Keybase proof
I hereby claim:
* I am beorn on github.
* I am beorno (https://keybase.io/beorno) on keybase.
* I have a public key ASD0XyKJ06dYdc1Du37H0Ki9s4hgAOHu-GjBh_0JqAxsEQo
To claim this, I am signing this object: