Skip to content

Commit

Permalink
Convenience properties for next and error on Event
Browse files Browse the repository at this point in the history
  • Loading branch information
neilpa committed May 23, 2015
1 parent 651d849 commit 4f178e5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ReactiveCocoa/Swift/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ public enum Event<T, E: ErrorType> {
return .Interrupted
}
}

/// Unwraps the contained `Next` value.
public var nextValue: T? {
switch self {
case let .Next(next):
return next.value
default:
return nil
}
}

/// Unwraps the contained `Error` value.
public var errorValue: E? {
switch self {
case let .Error(error):
return error.value
default:
return nil
}
}

/// Creates a sink that can receive events of this type, then invoke the
/// given handlers based on the kind of event received.
Expand Down

0 comments on commit 4f178e5

Please sign in to comment.