How to use the svelte.getContext function in svelte

To help you get started, we’ve selected a few svelte examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / luigi / core / src / navigation / LogoTitle.html View on Github external
export let logo;
  export let hasLogo;
  export let title;
  export let hasApps;
  export let dropDownStates = {};
  export let showMainAppEntry;
  export let selectedItem;
  export let defaultTitle;
  export let appSwitcherItems;
  export let pathParams;
  export let subTitle;
  export let defaultSubTitle;
  export let pathData;
  let previousPathData;
  let getUnsavedChangesModalPromise = getContext(
    'getUnsavedChangesModalPromise'
  );
  let getTranslation = getContext('getTranslation');
  let store = getContext('store');

  //TODO refactor
  const getComponentWrapper = () => {
    return {
      get: () => {
        return {
          pathData,
          pathParams,
          appSwitcherItems,
          selectedItem,
          defaultTitle,
          title,
github SAP / luigi / core / src / navigation / TopNav.html View on Github external
export let pathData;
  let previousPathData;
  export let pathParams;
  export let dropDownStates = {};
  export let children;
  export let selectedNode;
  export let visibleNodeCount;
  export let totalBadgeNode;
  export let isProductSwitcherAvailable;
  export let productSwitcherConfig;
  export let openMobileDropDown;
  export let nodeForMobile;
  export let profileItemsAvailable;
  export let userInfo = {};
  export let urlAuthError;
  let store = getContext('store');

  const setTopNavData = async () => {
    if (pathData && 0 < pathData.length) {
      const tnd = await NavigationHelpers.generateTopNavNodes(pathData);
      children = tnd.children;
      selectedNode = tnd.selectedNode;
      visibleNodeCount = tnd.visibleNodeCount;
      totalBadgeNode = tnd.totalBadgeNode;
      window.TOPNAVDATA = tnd.children;
      previousPathData = pathData;
    }
  };

  const setLoggedInState = () => {
    isLoggedIn = AuthHelpers.isLoggedIn();
  };
github TalesMUD / talesmud / public / app / src / auth.js View on Github external
function getAuth() {
  return getContext(AUTH_KEY);
}
github pshrmn / curi / packages / svelte / src / index.js View on Github external
export function getResponse() {
  return getContext(responseKey);
}
export function getNavigation() {
github qutran / swheel / src / Router / utils / register.js View on Github external
export function createRoute({ path, exact, depth }) {
  const isProtected = getProtected();
  const isRenderUnlocked = getContext(CONTEXT_RENDER_UNLOCKED);
  const context = getContext(CONTEXT_ROUTER_KEY);
  const { currentPath } = getHistory();

  const subject = derived(
    [isProtected, currentPath],
    ([$isProtected, $currentPath]) =>
      $isProtected && matchPath($currentPath, { path, exact }),
  );

  const routeData = { path, exact, isProtected, depth, subject };

  context.add(routeData);
  onDestroy(() => context.remove(routeData));

  return [subject, isRenderUnlocked];
}
github TalesMUD / talesmud / public / app / src / game / Client.js View on Github external
function getClient() {
  return getContext(GAME_CLIENT);
}
github SAP / luigi / core / src / SplitView.html View on Github external
iframe: null,
    split: null
  };
  let lastNode;
  let pathData;
  let nodeParams;
  let currentNode;
  let messageHandler;
  let splitViewIframe;
  let splitViewIframeData;
  export let nodepath;
  export let collapsed;
  export let splitViewSettings = {};
  export let isDataPrepared = false;
  let wasDataPrepared = false;
  let getUnsavedChangesModalPromise = getContext(
    'getUnsavedChangesModalPromise'
  );

  //TODO refactor
  const getComponentWrapper = () => {
    return {
      get: () => {
        return {
          collapsed,
          splitViewSettings,
          isDataPrepared,
          lastNode,
          pathData,
          nodeParams,
          currentNode,
          splitViewIframe,