本文整理汇总了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;
}
}
示例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;
};
示例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);
}
示例4: callFinally
callFinally(tokenPromise, () => { status.dispose(); });