58 lines
2.4 KiB
Plaintext
58 lines
2.4 KiB
Plaintext
//
|
|
// Driver+Operators+arity.swift
|
|
// Rx
|
|
//
|
|
// Created by Krunoslav Zaher on 10/14/15.
|
|
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
#if !RX_NO_MODULE
|
|
import RxSwift
|
|
#endif
|
|
|
|
<% for i in 2 ... 8 { %>
|
|
|
|
// <%= i %>
|
|
|
|
extension Driver {
|
|
/**
|
|
Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
|
|
|
|
- parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources.
|
|
- returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
|
*/
|
|
@warn_unused_result(message="http://git.io/rxs.uo")
|
|
public static func zip<<%= (Array(1...i).map { "O\($0): DriverConvertibleType" }).joinWithSeparator(", ") %>>
|
|
(<%= (Array(1...i).map { "source\($0): O\($0)" }).joinWithSeparator(", _ ") %>, resultSelector: (<%= (Array(1...i).map { "O\($0).E" }).joinWithSeparator(", ") %>) throws -> E)
|
|
-> Driver<E> {
|
|
let source = Observable.zip(
|
|
<%= (Array(1...i).map { "source\($0).asDriver().asObservable()" }).joinWithSeparator(", ") %>,
|
|
resultSelector: resultSelector
|
|
)
|
|
|
|
return Driver(source)
|
|
}
|
|
}
|
|
|
|
extension Driver {
|
|
/**
|
|
Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
|
|
|
|
- parameter resultSelector: Function to invoke whenever any of the sources produces an element.
|
|
- returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
|
*/
|
|
@warn_unused_result(message="http://git.io/rxs.uo")
|
|
public static func combineLatest<<%= (Array(1...i).map { "O\($0): DriverConvertibleType" }).joinWithSeparator(", ") %>>
|
|
(<%= (Array(1...i).map { "source\($0): O\($0)" }).joinWithSeparator(", _ ") %>, resultSelector: (<%= (Array(1...i).map { "O\($0).E" }).joinWithSeparator(", ") %>) throws -> E)
|
|
-> Driver<E> {
|
|
let source = Observable.combineLatest(
|
|
<%= (Array(1...i).map { "source\($0).asDriver().asObservable()" }).joinWithSeparator(", ") %>,
|
|
resultSelector: resultSelector
|
|
)
|
|
|
|
return Driver(source)
|
|
}
|
|
}
|
|
|
|
<% } %> |