本文整理匯總了TypeScript中backlive/utility.Common類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Common類的具體用法?TypeScript Common怎麽用?TypeScript Common使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Common類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor(startAmt, endAmt, startDate, endDate) {
this.startDate = startDate;
this.endDate = endDate;
var dateDiff = Common.dateDiff(Common.parseDate(this.startDate), Common.parseDate(this.endDate), 365);
this.return = endAmt / startAmt;
this.cagr = parseFloat(((Math.pow(this.return, 1 / dateDiff) - 1) * 100).toFixed(2));
this.return = parseFloat(((this.return - 1) * 100).toFixed(2));
}
示例2: setTimeout
notify<T>(eventName: string, data: T = null) {
if (this.Events[eventName]) {
setTimeout(() => {
var cnt = 0;
//notify any services first
if(this.Events[eventName][this.ServiceComponentId]) {
this.notifyComponent<T>(this.ServiceComponentId, eventName, data);
}
for(var componentId in this.Events[eventName]) {
if(componentId != this.ServiceComponentId) {
this.notifyComponent<T>(componentId, eventName, data);
}
cnt++;
}
if(cnt == 0) {
Common.log('EVENT: ' + eventName + ' has no subscribers');
}
else {
//Common.log('EVENT: ' + eventName + ' fired to ' + cnt + ' subscribers with data', data);
}
});
}
else {
Common.log('EVENT: ' + eventName + ' has no subscribers');
}
}
示例3: callback
notify<T>(eventName: string, data: T = null) {
if (this.Events[eventName]) {
//Common.log('EVENT: ' + eventName + ' fired to ' + this.Events[eventName].length + ' subscribers with data', data);
for(var classType in this.Events[eventName]) {
this.Events[eventName][classType].forEach((callback: Function) => {
callback(data);
});
}
}
else {
Common.log('EVENT: ' + eventName + ' has no subscribers');
}
}
示例4: subscribe
subscribe(eventName: string, classInstance: any, callback: Function) {
var classType = classInstance.constructor.name;
if(classType) {
if (!this.Events[eventName]) {
this.Events[eventName] = {};
}
if(!this.Events[eventName][classType]) {
this.Events[eventName][classType] = [];
}
this.Events[eventName][classType].push(callback);
}
else {
Common.log('Constructor Name not supported: ' + eventName + ' could not be subscribed to');
}
}
示例5: processError
private processError(err: Response) {
if(err) {
Common.log(err);
var res = err.json();
if(this.apiService.getToken() && res.message && res.message.indexOf('Authorization has been denied') >= 0) {
this.apiService.setToken(null);
this.appService.notify(AppEvent.ReloadApp);
}
else {
if (Config.SHOW_ERRORS) {
this.appService.notify(AppEvent.OpenModal, { title: "API Request Error", body: JSON.stringify(res) });
}
else {
this.appService.notify(AppEvent.MessageBar, 'an unexpected error occurred');
}
}
}
}