Skip to content

Instantly share code, notes, and snippets.

@sergdort
Created June 3, 2017 17:24
Show Gist options
  • Save sergdort/54cc33d5eb389ff766db75484fa104b9 to your computer and use it in GitHub Desktop.
Save sergdort/54cc33d5eb389ff766db75484fa104b9 to your computer and use it in GitHub Desktop.
public class Observable<Element>: ObservableType {
public typealias E = Element
private let _subscribeHandler: (Observer<Element>) -> Disposable
public init(_ subscribtionClosure: @escaping (Observer<Element>) -> Disposable) {
_subscribeHandler = subscribtionClosure
}
public func subscribe<O : ObserverType>(observer: O) -> Disposable where O.E == E {
let sink = Sink(forvard: observer, subscribtionHandler: _subscribeHandler)
sink.run()
return sink
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment