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


TypeScript status.StatusMessage類代碼示例

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


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

示例1: makeDefaultViewer

export function makeDefaultViewer(options?: Partial<ViewerOptions>) {
  disableContextMenu();
  disableWheel();
  try {
    let display = new DisplayContext(document.getElementById('neuroglancer-container')!);
    return new Viewer(display, options);
  } catch (error) {
    StatusMessage.showMessage(`Error: ${error.message}`);
    throw error;
  }
}
開發者ID:google,項目名稱:neuroglancer,代碼行數:11,代碼來源:default_viewer.ts

示例2: function

implementation.getNewTokenPromise = function() {
  let status = new StatusMessage(/*delay=*/true);
  let authPromise: Promise<Token>|undefined|null;
  let tokenPromise = new Promise(function(resolve) {
    function writeLoginStatus(
        msg = 'Brain Maps authorization required.', linkMessage = 'Request authorization.') {
      status.setText(msg + '  ');
      let button = document.createElement('button');
      button.textContent = linkMessage;
      status.element.appendChild(button);
      button.addEventListener('click', () => { login(/*immediate=*/false); });
      status.setVisible(true);
    }
    function login(immediate: boolean) {
      if (authPromise !== undefined) {
        cancelPromise(authPromise);
      }
      writeLoginStatus('Waiting for Brain Maps authorization...', 'Retry');
      authPromise = authenticateGoogleOAuth2({
        clientId: BRAINMAPS_CLIENT_ID,
        scopes: [BRAINMAPS_SCOPE],
        immediate: immediate,
        authUser: 0,
      });
      authPromise.then(
          token => {
            token['generationId'] = nextGenerationId++;
            resolve(token);
          },
          reason => {
            if (immediate) {
              writeLoginStatus();
            } else {
              writeLoginStatus(`Brain Maps authorization failed: ${reason}.`, 'Retry');
            }
          });
      callFinally(authPromise, () => { authPromise = undefined; });
    }
    login(/*immediate=*/true);
  });
  callFinally(tokenPromise, () => { status.dispose(); });
  return tokenPromise;
};
開發者ID:funkey,項目名稱:neuroglancer,代碼行數:43,代碼來源:api_frontend.ts

示例3: writeLoginStatus

 function writeLoginStatus(msg = 'Brain Maps authorization required.', linkMessage = 'Request authorization.') {
   status.setText(msg + '  ');
   let button = document.createElement('button');
   button.textContent = linkMessage;
   status.element.appendChild(button);
   button.addEventListener('click', () => { login(/*immediate=*/false); });
   status.setVisible(true);
 }
開發者ID:j6k4m8,項目名稱:neuroglancer,代碼行數:8,代碼來源:api_frontend.ts

示例4: callFinally

 callFinally(tokenPromise, () => { status.dispose(); });
開發者ID:j6k4m8,項目名稱:neuroglancer,代碼行數:1,代碼來源:api_frontend.ts


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