context_helpers.ts

Declarations
#

view source

create_context
#

context_helpers.ts view source

<T>(fallback: () => T): { get: () => T; set: (value?: T | undefined) => T; }

Wraps Svelte's setContext and getContext for better ergonomics. When no value is set in the context, get throws an error and get_maybe returns undefined. If a fallback is provided, the value argument to set is optional and get_maybe is omitted from the type.

fallback

type () => T

returns

{ get: () => T; set: (value?: T | undefined) => T; }

generics

T

Imported by
#