Retlang:取消订阅频道的最佳方式是什么?
我不确定使用 Retlang 时取消订阅频道的最佳方式是什么。
当您通过调用 ISubscriber
进行订阅时,您将返回一个 IUnsubscriber
。该接口没有方法。
再往上一层,IChannel
也没有任何方法。
我唯一能想到的是将 ISubscriber
转换为具体的 Channel
并调用其 Unsubscribe()
方法或向 ISubscriber
添加 Unsubscribe()
方法。
我只是好奇在我修改代码之前是否有人知道他们的想法。
I'm not sure what is the best way to unsubscribe from a channel when using Retlang.
When you subscribe by calling ISubscriber<T>::Subscribe(...)
you are returned an IUnsubscriber
. This interface has no methods.
Going up a level, IChannel<T>
also does not have any methods.
The only thing I can think of is casting an ISubscriber<T>
to the concrete Channel<T>
and calling its Unsubscribe()
method or adding an Unsubscribe()
method to ISubscriber<T>
.
I'm just curious if anyone knows what they had in mind before I modify the code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IUnsubscriber
接口实现IDisposable
。只需在您收到的IUnsubscriber
句柄上调用Dispose()
,它就会自行取消订阅。The
IUnsubscriber
interface implementsIDisposable
. Just callDispose()
on theIUnsubscriber
handle you receive, and it should unsubscribe itself.