Skip to content

ios: update unary/streaming & add test#354

Merged
rebello95 merged 2 commits intomasterfrom
swift-unary-v2
Aug 20, 2019
Merged

ios: update unary/streaming & add test#354
rebello95 merged 2 commits intomasterfrom
swift-unary-v2

Conversation

@rebello95
Copy link
Copy Markdown
Contributor

@rebello95 rebello95 commented Aug 20, 2019

Per the discussion here, updating the unary and streaming interfaces.

  • Moved the non-streaming convenience function into an extension on the protocol type so that it's available to all consumers
  • Added a test to validate the default behavior of this extension function
  • Added a CancelableStream protocol which includes a subset of functionality from the StreamEmitter, allowing consumers of the unary function to cancel requests without having the ability to send additional data into the stream

Signed-off-by: Michael Rebello me@michaelrebello.com

Per the discussion [here](#312 (comment)), updating the unary and streaming interfaces.

Also moving the non-streaming convenience function into an extension on the protocol type so that it's available to all consumers.

Lastly, added a test to validate the default behavior of this extension function.

Signed-off-by: Michael Rebello <me@michaelrebello.com>
@discardableResult
public func send(_ request: Request, data: Data?,
trailers: [String: [String]] = [:], handler: ResponseHandler)
-> CancelableStream
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CancelableStream is very clever; I like this approach.

Signed-off-by: Michael Rebello <me@michaelrebello.com>
Copy link
Copy Markdown
Contributor

@goaway goaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Copy link
Copy Markdown

@buildbreaker buildbreaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a suggestion but I do feel that it's a bit awkward that we return an Emitter in one case but we return a Stream in another

We can change it later but that's my only thought here. The general ideas and APIs are 💯

@rebello95
Copy link
Copy Markdown
Contributor Author

@buildbreaker thanks for the callout - we can do something like CancelEmitter in the future if that makes sense 🤷‍♂

@rebello95 rebello95 merged commit 537be8e into master Aug 20, 2019
@rebello95 rebello95 deleted the swift-unary-v2 branch August 20, 2019 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants