Skip to content

Instantly share code, notes, and snippets.

@Vadim-Yelagin
Last active October 19, 2016 14:08
Show Gist options
  • Save Vadim-Yelagin/258b2c47e9d8c5ccbcd7f70d6c848da2 to your computer and use it in GitHub Desktop.
Save Vadim-Yelagin/258b2c47e9d8c5ccbcd7f70d6c848da2 to your computer and use it in GitHub Desktop.
func animatingContext(duration: TimeInterval) -> ((@escaping (Void) -> Void) -> Void) {
return { UIView.animate(withDuration: duration, animations: $0) }
}
public extension SignalProtocol {
public func observe(context: @escaping (@escaping (Void) -> Void) -> Void) -> Signal<Value, Error> {
return Signal { observer in
return self.observe { event in
switch event {
case .value:
context({ observer.action(event) })
default:
observer.action(event)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment