I am trying to create an Rx operator that works on arrays. I've tried this simple extension:
extension ObservableType where Element == Array<Any> {
func beat<U>(_ beat: Observable<U>) -> Observable<Element.Element> {
let lhs = self.flatMap { Observable.from($0) }
return Observable.zip(lhs, beat).map { $0.0 }
}
}
Now, I've noted Array<Any>
because the otherwise I get
Reference to generic type 'Array' requires arguments in <...>
, but this way the return value is of courses Observable<Any>
.
Is it even possible to return an observable with the actual Element
of the array?