本文整理汇总了TypeScript中ng-jhipster.EventManager.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript EventManager.subscribe方法的具体用法?TypeScript EventManager.subscribe怎么用?TypeScript EventManager.subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ng-jhipster.EventManager
的用法示例。
在下文中一共展示了EventManager.subscribe方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: registerAuthenticationSuccess
registerAuthenticationSuccess() {
this.eventManager.subscribe('authenticationSuccess', (message) => {
this.principal.identity().then((account) => {
this.account = account;
});
});
}
示例2: constructor
constructor(private alertService: AlertService, private eventManager: EventManager, private translateService: TranslateService) {
this.alerts = [];
this.cleanHttpErrorListener = eventManager.subscribe('baeldungApp.httpError', (response) => {
let i;
let httpResponse = response.content;
switch (httpResponse.status) {
// connection refused, server not reachable
case 0:
this.addErrorAlert('Server not reachable', 'error.server.not.reachable');
break;
case 400:
let arr = Array.from(httpResponse.headers._headers);
let headers = [];
for (i = 0; i < arr.length; i++) {
if (arr[i][0].endsWith('app-error') || arr[i][0].endsWith('app-params')) {
headers.push(arr[i][0]);
}
}
headers.sort();
let errorHeader = httpResponse.headers.get(headers[0]);
let entityKey = httpResponse.headers.get(headers[1]);
if (errorHeader) {
let entityName = translateService.instant('global.menu.entities.' + entityKey);
this.addErrorAlert(errorHeader, errorHeader, {entityName: entityName});
} else if (httpResponse.text() !== '' && httpResponse.json() && httpResponse.json().fieldErrors) {
let fieldErrors = httpResponse.json().fieldErrors;
for (i = 0; i < fieldErrors.length; i++) {
let fieldError = fieldErrors[i];
// convert 'something[14].other[4].id' to 'something[].other[].id' so translations can be written to it
let convertedField = fieldError.field.replace(/\[\d*\]/g, '[]');
let fieldName = translateService.instant('baeldungApp.' +
fieldError.objectName + '.' + convertedField);
this.addErrorAlert(
'Field ' + fieldName + ' cannot be empty', 'error.' + fieldError.message, {fieldName: fieldName});
}
} else if (httpResponse.text() !== '' && httpResponse.json() && httpResponse.json().message) {
this.addErrorAlert(httpResponse.json().message, httpResponse.json().message, httpResponse.json());
} else {
this.addErrorAlert(httpResponse.text());
}
break;
case 404:
this.addErrorAlert('Not found', 'error.url.not.found');
break;
default:
if (httpResponse.text() !== '' && httpResponse.json() && httpResponse.json().message) {
this.addErrorAlert(httpResponse.json().message);
} else {
this.addErrorAlert(JSON.stringify(httpResponse)); // Fixme find a way to parse httpResponse
}
}
});
}
示例3: registerChangeInComments
registerChangeInComments() {
this.eventSubscriber = this.eventManager.subscribe('commentListModification', (response) => this.reset());
}
示例4: registerChangeInProductReviews
registerChangeInProductReviews() {
this.eventSubscriber = this.eventManager.subscribe('productReviewListModification', (response) => this.load(this.productReview.id));
}
示例5: registerChangeInContentDescriptions
registerChangeInContentDescriptions() {
this.eventSubscriber = this.eventManager.subscribe('contentDescriptionListModification', (response) => this.load(this.contentDescription.id));
}
示例6: registerChangeInUsers
registerChangeInUsers() {
this.eventManager.subscribe('userListModification', (response) => this.loadAll());
}
示例7: registerChangeInFileHistories
registerChangeInFileHistories() {
this.eventSubscriber = this.eventManager.subscribe('fileHistoryListModification', (response) => this.loadAll());
}
示例8: registerChangeInWishes
registerChangeInWishes() {
this.eventSubscriber = this.eventManager.subscribe('wishListModification', response => this.load(this.wish.id));
}
示例9: registerChangeInTransactions
registerChangeInTransactions() {
this.eventSubscriber = this.eventManager.subscribe('transactionListModification', (response) => this.loadAll());
}
示例10: registerChangeInZones
registerChangeInZones() {
this.eventSubscriber = this.eventManager.subscribe('zoneListModification', (response) => this.load(this.zone.id));
}