Observable.Create from Boo 的类型问题
我正在尝试使用 Boo 的反应式扩展,但遇到了类型问题。这是基本示例:
def OnSubscribe(observer as IObservable[of string]) as callable:
print "subscribing"
def Dispose():
print "disposing"
return Dispose
observable = System.Linq.Observable.Create[of string](OnSubscribe)
observer = System.Linq.Observer.Create[of string]({x as string | print x})
observable.Subscribe(observer)
此处的 Subscribe 给出了 System.InvalidCastException:无法从源类型转换为目标类型。问题似乎在于我如何创建可观察的,但我一直在努力找出类型问题的根源。
有想法吗?
I'm trying to use Reactive Extensions from Boo and am running into type problems. Here's the basic example:
def OnSubscribe(observer as IObservable[of string]) as callable:
print "subscribing"
def Dispose():
print "disposing"
return Dispose
observable = System.Linq.Observable.Create[of string](OnSubscribe)
observer = System.Linq.Observer.Create[of string]({x as string | print x})
observable.Subscribe(observer)
The Subscribe here gives a System.InvalidCastException: Cannot cast from source type to destination type. The issue appears to be with how I'm creating the observable, but I've struggled to see where the type problem arises from.
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Observable.Create
采用Func
,但您的OnSubscribe
接受IObservable
。试试这个:
Observable.Create
takesFunc<IObserver,Action>
, but yourOnSubscribe
accepts anIObservable
.Try this: