UNPKG

@kahi-ui/framework

Version:

Straight-forward Svelte UI for the Web

26 lines (25 loc) 562 B
import { getContext, hasContext, setContext } from "svelte"; /** * Returns Svelte Context Scoped helpers * * ```javascript * const {get, has, set} = make_scoped_context("my-context"); * ``` * * @param symbol * @returns */ export function make_scoped_context(identifier) { const symbol = Symbol.for(`kahi-ui-${identifier}`); return { get() { return getContext(symbol); }, has() { return hasContext(symbol); }, set(value) { setContext(symbol, value); }, }; }