首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >功能链不工作角5

功能链不工作角5
EN

Stack Overflow用户
提问于 2018-06-26 06:10:45
回答 1查看 43关注 0票数 1

对不起,不完全是函数链,但我有以下代码

代码语言:javascript
复制
ActivityService._hubConnection.on('Send', (activity: ActivityDto) => {
   this.activity = activity;
   if (activity.title === 'LOGIN') {
      this.showActivity(`${activity.user.firstName} ${activity.user.surname} logged in.`);
   } else if (activity.title === 'COMMENT') {
      this.showActivity(`${activity.user.firstName} ${activity.user.surname} commented on: XB-ID-${activity.messageId}`, `/app/main/dashboard/xpert-detail/${activity.messageId}/comment`, null);
   } else if (activity.title === 'ASSIGNED') {
      this.showActivity(`${activity.user.firstName} ${activity.user.surname} assigned: XB-ID-${activity.messageId}`, `/app/main/dashboard/xpert-detail/${activity.messageId}/comment`);
   } else if (activity.title === 'SYNC COMPLETE') {
      this.showActivity(`Sync complete, View Changes`, `/app/main/dashboard/alerts/all`, 'complete');
   } else if (activity.title === 'FILE') {
      this.showActivity(`${activity.user.firstName} ${activity.user.surname} filed: XB-ID-${activity.messageId}`, `/app/main/dashboard/xpert-detail/${activity.messageId}/comment`)
   } else if (activity.title === 'XPERT SYNC') {
      this.showActivity(`Sync In Progress.`, `/app/main/dashboard/activity`, 'start' );
   }
});

 showActivity(popText, notifLink = null, sync = null) {
    this.popupText = popText;
    if (notifLink !== null) {
        this.notifLink = notifLink;
    }
    if (sync !== null) {
        if (sync === 'complete') {
            this._activityService.finishSync();
        } else if (sync === 'start') {
            this._activityService.startSync();
        }
    }
    this.showNotif();
}

showNotif() {
    const notif = <HTMLElement>document.querySelector('.notification-tab');
    notif.style.display = 'flex';
    notif.style.bottom = '0';
    setTimeout(() => {
        notif.style.bottom = '-50px';
        setTimeout(() => {
            notif.style.display = 'none';
        }, 500);
    }, 5000);
}

现在我不明白为什么这不起作用了,基本上是说我收到了评论,所以activity.title ===‘注释’,它应该运行showActivity()函数,然后运行showNotif()函数,我在函数的每个部分放置断点,断点到达this.showActivity(),但是什么都没有发生?没有其他的断点被击中,我不知道是什么问题!对我来说没有任何意义。

任何帮助都会很感激,我不知道会出什么问题.

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-26 06:30:36

尝试包装你的函数来尝试..。抓住,也许有未捕获的例外。

代码语言:javascript
复制
  showActivity(popText, notifLink = null, sync = null) {
   try  {
    this.popupText = popText;
    if (notifLink !== null) {
      this.notifLink = notifLink;
    }
    if (sync !== null) {
      if (sync === 'complete') {
        this._activityService.finishSync();
      } else if (sync === 'start') {
        this._activityService.startSync();
      }
    }
    this.showNotif();
   } catch (e) {
    console.error(e);
   }
}

(也包在这里)

代码语言:javascript
复制
if (activity.title === 'COMMENT') {
  try {
    this.showActivity(`${activity.user.firstName} ${activity.user.surname} commented on: XB-ID-${activity.messageId}`, `/app/main/dashboard/xpert-detail/${activity.messageId}/comment`, null);
  } catch (e) {
    console.error(e);
  }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51035960

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档