當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript bootstrap.paramChangedHelper函數代碼示例

本文整理匯總了TypeScript中core/bootstrap.paramChangedHelper函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript paramChangedHelper函數的具體用法?TypeScript paramChangedHelper怎麽用?TypeScript paramChangedHelper使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了paramChangedHelper函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: new

bootstrapModule.run(($uiRouter: UIRouter) => {
  'ngInject';

  let visualizerEnabled = false;
  let VisualizerPlugin: { new (): UIRouterPlugin } = null;

  const loadVisualizer = () => {
    // Auto-collapse certain states with lots of children
    const collapseGlobs = ['home.*', 'home.*.application.*', 'home.*.application.insight.*'].map(
      globStr => new Glob(globStr),
    );
    const collapsedStates = $uiRouter.stateRegistry
      .get()
      .filter(state => collapseGlobs.some(glob => glob.matches(state.name)));
    collapsedStates.forEach(state => ((state.$$state() as any)._collapsed = true));

    return System.import('@uirouter/visualizer')
      .then((vis: any) => (VisualizerPlugin = vis.Visualizer))
      .then(createVisualizer);
  };

  const createVisualizer = () => {
    if (!visualizerEnabled) {
      return;
    }

    // Cleanup any current visualizer first
    destroyVisualizer();

    if (VisualizerPlugin) {
      $uiRouter.plugin(VisualizerPlugin);
    } else {
      loadVisualizer();
    }
  };

  const destroyVisualizer = () => {
    const plugin = $uiRouter.getPlugin('visualizer');
    plugin && $uiRouter.dispose(plugin);
  };

  const toggleVisualizer = (enabled: boolean) => {
    if (enabled === visualizerEnabled) {
      return;
    }
    visualizerEnabled = enabled;

    if (enabled) {
      return createVisualizer();
    } else {
      return destroyVisualizer();
    }
  };

  (window as any).vis = createVisualizer;
  $uiRouter.transitionService.onBefore({}, paramChangedHelper('vis', toggleVisualizer));
});
開發者ID:mizzy,項目名稱:deck,代碼行數:57,代碼來源:uiRouterVisualizer.toggle.ts

示例2: if

  ($uiRouter: UIRouter) => {
    const changeTraceSetting = (newValue: string) => {
      const trace = $uiRouter.trace;
      trace.disable();
      if (typeof newValue === 'string') {
        if (newValue.toUpperCase() === 'TRUE') {
          trace.enable(Category.TRANSITION);
        } else if (newValue.toUpperCase() === 'ALL') {
          trace.enable();
        } else {
          const traceValues = newValue.split(',').map(str => str.trim().toUpperCase());
          trace.enable(...(traceValues as any));
        }
      }
    };

    $uiRouter.transitionService.onBefore({}, paramChangedHelper('trace', changeTraceSetting));
  },
開發者ID:emjburns,項目名稱:deck,代碼行數:18,代碼來源:transitionTrace.toggle.ts


注:本文中的core/bootstrap.paramChangedHelper函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。