Skip to content

Commit 33d415f

Browse files
committed
Add a .Launch case to TaskEvent
1 parent f310f88 commit 33d415f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ReactiveTask/Task.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ public protocol TaskEventType {
301301
/// Represents events that can occur during the execution of a task that is
302302
/// expected to terminate with a result of type T (upon success).
303303
public enum TaskEvent<T>: TaskEventType {
304+
/// The task was launched.
305+
case Launch(Task)
306+
304307
/// Some data arrived from the task on `stdout`.
305308
case StandardOutput(NSData)
306309

@@ -314,7 +317,7 @@ public enum TaskEvent<T>: TaskEventType {
314317
/// The resulting value, if the event is `Success`.
315318
public var value: T? {
316319
switch self {
317-
case .StandardOutput, .StandardError:
320+
case .Launch, .StandardOutput, .StandardError:
318321
return nil
319322

320323
case let .Success(value):
@@ -325,6 +328,9 @@ public enum TaskEvent<T>: TaskEventType {
325328
/// Maps over the value embedded in a `Success` event.
326329
public func map<U>(@noescape transform: T -> U) -> TaskEvent<U> {
327330
switch self {
331+
case let .Launch(task):
332+
return .Launch(task)
333+
328334
case let .StandardOutput(data):
329335
return .StandardOutput(data)
330336

@@ -339,6 +345,9 @@ public enum TaskEvent<T>: TaskEventType {
339345
/// Convenience operator for mapping TaskEvents to SignalProducers.
340346
public func producerMap<U, Error>(@noescape transform: T -> SignalProducer<U, Error>) -> SignalProducer<TaskEvent<U>, Error> {
341347
switch self {
348+
case let .Launch(task):
349+
return SignalProducer<TaskEvent<U>, Error>(value: .Launch(task))
350+
342351
case let .StandardOutput(data):
343352
return SignalProducer<TaskEvent<U>, Error>(value: .StandardOutput(data))
344353

@@ -353,6 +362,9 @@ public enum TaskEvent<T>: TaskEventType {
353362

354363
public func == <T: Equatable>(lhs: TaskEvent<T>, rhs: TaskEvent<T>) -> Bool {
355364
switch (lhs, rhs) {
365+
case let (.Launch(left), .Launch(right)):
366+
return left == right
367+
356368
case let (.StandardOutput(left), .StandardOutput(right)):
357369
return left == right
358370

@@ -374,6 +386,9 @@ extension TaskEvent: CustomStringConvertible {
374386
}
375387

376388
switch self {
389+
case let .Launch(task):
390+
return "launch: \(task)"
391+
377392
case let .StandardOutput(data):
378393
return "stdout: " + dataDescription(data)
379394

0 commit comments

Comments
 (0)