本文整理汇总了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');
}
}
}
}