angular2样式指南-具有美元符号的属性? [英] angular2 style guide - property with dollar sign?

查看:193
本文介绍了angular2样式指南-具有美元符号的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

angular2代码示例,我们看到了一些带有$符号的公共财产:

Looking at angular2 code example, we see some public properties with $ sign:

  <....>
  private missionAnnouncedSource = new Subject<string>();
  private missionConfirmedSource = new Subject<string>();
  // Observable string streams
  missionAnnounced$ = this.missionAnnouncedSource.asObservable();
  missionConfirmed$ = this.missionConfirmedSource.asObservable();
  <....>

任何人都可以解释:

  • 为什么使用$(此符号背后的原因是什么?始终将其用于公共财产)?
  • 使用了公共属性,但未使用方法(例如,missionAnnouncements(),missionConfirmations())-再次说明,这是否是ng2应用的约定?

在官方样式指南中似乎没有关于此 的任何内容?

Does not seem there is anything regarding this in the official style guide ?

推荐答案

$后缀(由 Cycle.js )用于指示该变量是 可观察 . 它也可以加入官方样式指南,但还不存在

$ suffix (popularized by Cycle.js) is used to indicate that the variable is an Observable. It could make it to the official style guide too but it's not there yet

在此处了解更多信息:

Read more here : What does the suffixed dollar sign $ mean?

更新: 在Angular网站上阅读有关尾随"$"符号的更多信息: https://angular.io/guide/rx-library#naming-conventions -for-observables

Update: Read more about the trailing "$" sign on Angular website here: https://angular.io/guide/rx-library#naming-conventions-for-observables

这篇关于angular2样式指南-具有美元符号的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆