A PropertySource is an interface that allows a configuration value to be loaded by its name. An implementation may either be sync or async depending on its backing implmentation.
interface PropertySource {
get(key: string): unknown;
}
interface ResourcePoolOptions<T> { | |
defaultSize: number; | |
maxSize: number; | |
create: () => T; | |
} | |
interface Resource<T> extends Disposable { | |
value: T; | |
} |
interface Machine<State extends string, Event extends string> { | |
initialState: State; | |
transition(currentState: State, event: Event): State; | |
} | |
interface MachineDefinition<State extends string, Event extends string> { | |
initialState: State; | |
states: Record<State, Record<Event, State>>; | |
} |
interface State<Value extends string, Context> { | |
value: Value; | |
context: Context; | |
} | |
const ASSIGN_TYPE = Symbol('Assign'); | |
type AssignAction<Context> = { | |
type: typeof ASSIGN_TYPE; | |
exec(context: Context): Context; |
interface Machine<State extends string, Event extends string> { | |
initialState: State; | |
transition(currentState: State, event: Event): State; | |
} | |
interface MachineDefinition<State extends string, Event extends string> { | |
initialState: State; | |
states: Record<State, { | |
entry?(): void; | |
exit?(): void; |
import { Atom } from 'jotai'; | |
import { selectAtom, useAtomValue} from 'jotai/utils'; | |
import { useMemo } from 'react'; | |
import { createTrackedSelector } from 'react-tracked'; | |
type ResolveType<T> = T extends Promise<infer V> ? V : T | |
export function useSelectAtom<Value, Slice>( | |
atom: Atom<Value>, | |
selector: (v: ResolveType<Value>) => Slice, |
import { useLayoutEffect, useState } from 'react'; | |
import { EventObject, MachineOptions, StateMachine, Typestate } from 'xstate'; | |
type MaybeLazy<T> = T | (() => T); | |
export function useMachineOptions< | |
TContext, | |
TEvent extends EventObject, | |
TTypestate extends Typestate<TContext> = { value: any; context: TContext } | |
>( |
import { useRef, useState, MutableRefObject } from 'react'; | |
type ValueCallback<T> = (value: T) => void; | |
export type ObservableRef<T> = MutableRefObject<T> & { | |
subscribe(onNext: ValueCallback<T>): Subscription; | |
}; | |
export interface Subscription { | |
unsubscribe(): void; |
import { useState, useEffect, Dispatch, SetStateAction } from 'react'; | |
import { createContainer } from 'react-tracked'; | |
import { ActionFunction, EventObject, MachineOptions } from 'xstate'; | |
function createUseRegister<V extends object, T>(key: keyof V, useUpdate: () => Dispatch<SetStateAction<V>>) { | |
return function useRegister(name: string, value: T) { | |
const setState = useUpdate(); | |
useEffect(() => { | |
setState((options) => ({ |
if (!Symbol.observable) { | |
Symbol.observable = Symbol('observable') | |
} | |
export class Observable<T> { | |
readonly #subscriber: SubscriberFunction<T>; | |
constructor(subscriber : SubscriberFunction<T>) { | |
this.#subscriber = subscriber; | |
} |