在类打字稿中使用caveniOrSubject作为类/对象成员的抗模式吗?
我正在使用Angular,并且有几个类,其成员在Angular HTML模板中显示。这些课程具有这样的常见成员:
class Foo {
bar: string;
bas: Date;
}
在许多情况下,我必须手动刷新FOO对象成员的视图。由于我正在使用Angular,因此我可以使用 capation ucipiourSubject 来自 =“ https://rxjs.dev/guide/overview” rel =“ nofollow noreferrer”> rxjs 与 async 管道简化渲染检测。用行为主体替换许多类别/对象成员是反模式吗?有缺点吗?
class Foo {
bar: BehaviourSubject<string>;
bas: BehaviourSubject<Date>;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是反pattern的,但是您必须记住一些事情:
this.input = {... this.input,changeprop:newValue}
;我希望这会有所帮助!
I'm not sure it's an anti-pattern, but you have to remember a few things:
this.input = { ...this.input, changedProp: newValue }
;I hope this helps!