angular2样式指南-具有美元符号的属性? [英] angular2 style guide - property with dollar sign?
问题描述
看 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屋!