Skip to content

Instantly share code, notes, and snippets.

@alickbass
Last active June 20, 2017 09:37
Show Gist options
  • Save alickbass/a1e0459f4b1f93cce78a234554d066a4 to your computer and use it in GitHub Desktop.
Save alickbass/a1e0459f4b1f93cce78a234554d066a4 to your computer and use it in GitHub Desktop.
Rx with diffing components
import RxSwift
import ViewComponents
extension ObservableType where E: ComponentConvertible {
public func diff() -> Observable<Component<E.ComponentViewType>> {
return map({ $0.toComponent })
.scan((Component(), Component()), accumulator: { ($0.1, $1) })
.map({ $0.0.diffChanges(from: $0.1) })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment