@revenuecat/purchases-ui-js
Version:
Web components for Paywalls. Powered by RevenueCat
18 lines (17 loc) • 550 B
JavaScript
import { getContext, setContext } from "svelte";
import { readable } from "svelte/store";
const key = Symbol("variables");
export function setVariablesContext(variables) {
setContext(key, variables);
}
export function getVariablesContext() {
const context = getContext(key);
if (context === undefined) {
throw new Error("Variables context not found");
}
return context;
}
const emptyVariablesStore = readable(undefined);
export function getOptionalVariablesContext() {
return getContext(key) ?? emptyVariablesStore;
}