[英]ReactiveCocoa's equivalent to Observable.Create
I'd like to make a custom RACSignal, but I'd prefer to not have to make a whole class. 我想制作一个自定义的RACSignal,但我不想做一个完整的类。 I just want to specify a block to call when observers subscribe. 我只想指定观察者订阅时要调用的块。
In .Net's Rx I would do this: 在.Net的Rx中,我将执行以下操作:
return Observable.Create(observer => {
...
// send items to observer
...
return subscriptionDisposer;
});
Does ReactiveCocoa have equivalent functionality? ReactiveCocoa是否具有等效功能?
Self-answer: the RACSignal
class has a createSignal
method that acts like Observable.Create
. 自我解答: RACSignal
类具有createSignal
方法,其行为类似于Observable.Create
。
(I would have found it right away with autocomplete, but XCode's autocomplete HALF fails in lots of cases where you have half-written code above what you're editing. You get some results but not others. Bleh.) (我会立即发现它具有自动完成功能,但是XCode的自动完成功能HALF在许多情况下会失败,在这种情况下,您编写的代码超出了所编辑的内容的一半。您得到的是一些结果,而其他则没有。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.