在 API 中使用 ReactiveCollection 是否合适?

发布于 2025-01-02 06:57:10 字数 345 浏览 0 评论 0原文

在 API 中公开 ReactiveCollection 是否合适?具体来说,在将在多个应用程序内部使用的服务类中。但作为一个思想实验,我们也可以考虑在公共使用中。

我一直在研究 Rx 和 ReactiveUI,这些看起来都是强大的工具。但是,我没有足够的经验来确定要求其他人依赖它们是否是一个好主意。

更多详细信息:

我正在创建一个跟踪服务类来跟踪连接的客户端。在我看来,消费者使用此类所需要做的就是公开一个可观察的集合(可能是 ReactiveCollection),该集合公开连接的客户端,并通知由服务管理的集合的更改。代表连接的客户端的实体还将利用 INotifyPropertyChanged 来通知客户端状态的更新。

Is it appropriate to expose a ReactiveCollection in an API? Specifically, in a service class that would be used internally on multiple applications. But as a thought experiment, we can also consider in public use as well.

I've been investigating Rx and ReactiveUI, and these seem like powerful tools. However, I don't have enough experience with them to determine if it is a good idea to require others to take a dependency on them.

More details:

I'm creating a tracking service class that would track connected clients. From my view, all that would be necessary for consumers to use this class is to expose an observable collection (possibly a ReactiveCollection) that exposes the connected clients, and notifies of changes to the collection which are managed by the service. The entitity representing the connected clients would also take advantage of INotifyPropertyChanged to notify of updates to the clients' state.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡看悲欢离合 2025-01-09 06:57:10

由于 ReactiveCollection 是 .NET 的 ObservableCollection(即非 Rx WPF/SL 的)的衍生产品,因此您可以将其公开为 ObservableCollection。

Since ReactiveCollection is a derivative of .NET's ObservableCollection (i.e. the non-Rx WPF/SL one), you could expose it as an ObservableCollection instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文