Skip to content

Instantly share code, notes, and snippets.

@bqmackay
Last active January 15, 2021 23:35
Show Gist options
  • Save bqmackay/97f371e05afd33cde6dcc86fa7ee241d to your computer and use it in GitHub Desktop.
Save bqmackay/97f371e05afd33cde6dcc86fa7ee241d to your computer and use it in GitHub Desktop.
Whitespace Example
//Bad White Space
func request(_ demand: Subscribers.Demand) {
assert(demand > 0)
guard let downstream = downstream else { return }
self.downstream = nil
streamHandler { stream in
_ = downstream.receive(stream)
if case .complete = stream.event { downstream.receive(completion: .finished) }
}.resume()
}
//Good White Space
func request(_ demand: Subscribers.Demand) {
assert(demand > 0)
guard let downstream = downstream else { return }
self.downstream = nil
streamHandler { stream in
_ = downstream.receive(stream)
if case .complete = stream.event {
downstream.receive(completion: .finished)
}
}.resume()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment