2016-05-11 1 views

Antwort

1

Ich löste diese Aufgabe (für die Lage) und es ist meine Lösung

extention SignalProducer { 
    func accumulate(size: Int) -> SignalProducer<[Value], Error> { 
     var values: [Value] = [] 
     func next(value: Value) { 
      if values.count >= size { 
       values.removeAll() 
      } 
      values.append(value) 
     } 
     return on(next: next) 
      .filter { _ in values.count < size } 
      .map { _ -> [Value] in return values } 
    } 
} 

https://github.com/ReactiveCocoa/ReactiveCocoa/pull/2817

Verwandte Themen