Currently I am trying to get RxSwift working. And I want to create a custom Observable. But I think I am doing something wrong.
I have distilled what I do to this minimal sample:
import Foundation
import RxSwift
class Example
{
let exampleObservable : Observable<String> = Observable.create { (observer) in
observer.on(.Next("hello"))
observer.on(.Completed)
return AnonymousDisposable { }
}
let exampleObserver : AnyObserver<String>?
func run()
{
self.exampleObserver = exampleObservable.subscribeNext({ (text) -> Void in
print(text)
})
}
}
let ex = Example()
ex.run()
Is this correct? In the run method, the subscribeNext method is autocompleted that way by XCode.
But when I run it I get the following compilation error:
Cannot Invoke 'substribeNext' with an argument list of type ((String) -> Void)