How to use the svelte.setContext 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 / App.html View on Github external
!thirdPartyCookiesCheck.thirdPartyCookieScriptLocation &&
        'luigi.third-party-cookie' === e.data.msg
      ) {
        if (e.data.tpc === 'disabled') {
          tpcErrorHandling(thirdPartyCookiesCheck);
        }
      }
    });

    // listeners are not automatically removed — cancel
    // them to prevent memory leaks
    // this.on('destroy', storeListener.cancel);
    enableRouting(node, config);
  }

  setContext('store', store);
  setContext('getTranslation', getTranslation);

  const tpcErrorHandling = thirdpartycookiecheck => {
    if (
      thirdPartyCookiesCheck &&
      thirdPartyCookiesCheck.thirdPartyCookieErrorHandling &&
      GenericHelpers.isFunction(
        thirdPartyCookiesCheck.thirdPartyCookieErrorHandling
      )
    ) {
      thirdPartyCookiesCheck.thirdPartyCookieErrorHandling();
    }
  };

  export const pathExists = async path => {
    const data = {
github SAP / luigi / core / src / App.html View on Github external
const modalIframeCreated = event => {
    modalIframe = event.detail.modalIframe;
    modalIframeData = event.detail.modalIframeData;
  };

  const closeModal = () => {
    if (modalIframe) {
      getUnsavedChangesModalPromise(modalIframe.contentWindow).then(() => {
        mfModal = {
          displayed: false
        };
      });
    }
  };

  setContext('openViewInModal', openViewInModal);

  function init(node) {
    const isolateAllViews = LuigiConfig.getConfigValue(
      'navigation.defaults.isolateView'
    );
    const config = {
      iframe: null,
      navigateOk: null,
      builderCompatibilityMode: Boolean(window.builderCompatibilityMode),
      isolateAllViews
    };
    LuigiI18N.addCurrentLocaleChangeListener(locale => {
      const message = {
        msg: 'luigi.current-locale-changed',
        currentLocale: locale
      };
github qutran / swheel / src / Router / utils / basePath.js View on Github external
export function createBasePath(basePath) {
  setContext(CONTEXT_KEY, basePath);
}
github qutran / swheel / src / Router / utils / history / index.js View on Github external
function createHistory(baseHistory) {
  setContext(HISTORY_KEY, baseHistory);
  return baseHistory;
}
github pshrmn / curi / packages / svelte / src / index.js View on Github external
export function setup(router) {
  const initial = router.current();
  const response = readable(initial.response, set => {
    return router.observe(({ response }) => {
      set(response);
    });
  });
  const navigation = readable(initial.navigation, set => {
    return router.observe(({ navigation }) => {
      set(navigation);
    });
  });

  setContext(routerKey, router);
  setContext(responseKey, response);
  setContext(navigationKey, navigation);
}
github qutran / swheel / src / Router / utils / register.js View on Github external
export function getDepth() {
  const currentDepth = getContext(CONTEXT_DEPTH_KEY) + 1;
  setContext(CONTEXT_DEPTH_KEY, currentDepth);
  return currentDepth;
}
github pshrmn / curi / packages / svelte / src / index.js View on Github external
export function setup(router) {
  const initial = router.current();
  const response = readable(initial.response, set => {
    return router.observe(({ response }) => {
      set(response);
    });
  });
  const navigation = readable(initial.navigation, set => {
    return router.observe(({ navigation }) => {
      set(navigation);
    });
  });

  setContext(routerKey, router);
  setContext(responseKey, response);
  setContext(navigationKey, navigation);
}
github pshrmn / curi / packages / svelte / src / index.js View on Github external
export function setup(router) {
  const initial = router.current();
  const response = readable(initial.response, set => {
    return router.observe(({ response }) => {
      set(response);
    });
  });
  const navigation = readable(initial.navigation, set => {
    return router.observe(({ navigation }) => {
      set(navigation);
    });
  });

  setContext(routerKey, router);
  setContext(responseKey, response);
  setContext(navigationKey, navigation);
}