controller/topic.js异步协作问题
发布于 11 年前 作者 goooto 3610 次浏览 最后一次编辑是 8 年前
var events = [ 'topic', 'other_topics', 'no_reply_topics', 'get_relation', '[@user](/user/user)'];

var events = [ 'topic', 'other_topics', 'no_reply_topics', 'get_relation', '[@user](/user/user)'];
  var ep = EventProxy.create(events, function (topic, other_topics, no_reply_topics, relation) {
    res.render('topic/index', {
      topic: topic,
      author_other_topics: other_topics,
      no_reply_topics: no_reply_topics,
      relation : relation
    });
  });

ep.once('topic', function (topic) {
    if (topic.content_is_html) {
      return ep.emit('[@user](/user/user)');
    }
    at_ctrl.link_at_who(topic.content, function (err, content) {
      if (err) {
        return ep.emit(err);
      }
      topic.content = Util.xss(Showdown.parse(content));
      ep.emit('[@user](/user/user)');
    });
  });

[@user](/user/user)没看见ep.on绑定,只有 ep.emit('[@user](/user/user)');这怎么理解,还有这个@有什么特殊意义吗
3 回复

不是create了一组监听吗? @user也只是一个字符串而已呀!

create中就隐含了on

谢谢!

回到顶部