我想知道 getValue
之间的主要区别是什么函数和 readonly value
BehaviorSubject
上的属性(property)?使用一个比另一个有好处吗?
最佳答案
这两种方法没有区别。
内部BehaviorSubject
返回来自 getValue()
的值.因此,如果您对性能非常挑剔,请调用 getValue()
为您节省一个函数调用。
get value(): T {
return this.getValue();
}
https://github.com/ReactiveX/rxjs/blob/1d29fe8b903c0dbc2b74a5e68abb9270e3f45015/src/internal/BehaviorSubject.ts#L19
关于angular - RXJS BehaviorSubject getValue 与值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59899318/