Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds an optional writeCompletion callback #178

Merged
merged 1 commit into from
Mar 1, 2016
Merged

Adds an optional writeCompletion callback #178

merged 1 commit into from
Mar 1, 2016

Conversation

noremac
Copy link
Contributor

@noremac noremac commented Feb 29, 2016

I often need to write files that I'm lazily reading out of an NSInputStream. The addition of a writeCompletion callback to the write(data:) method lets me smartly/lazily frame up the next chunk to send as soon as the socket is ready for more.

That's what I'd want it for anyway :-)

@noremac noremac changed the title Adds an optional "write did complete" callback Adds an optional writeCompletion callback Feb 29, 2016
- parameter data: The data to write.
- parameter completion: The (optional) completion handler.
*/
public func writeData(data: NSData, completion: (() -> ())?) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we set completion to default to nil?

writeCompletion: (() -> ())? = nil

That way we can avoid can breaking changes for current versions that upgrade.

@acmacalister
Copy link
Collaborator

Looks good! Other than that one comment, can we also add the completion closure to writeString and writePing to be consistent? Thanks!

@noremac
Copy link
Contributor Author

noremac commented Mar 1, 2016

Oops, yes I had meant that to default to nil! I've updated writeString and writePing as well, good idea.

I did not update the comment for writePing as I'm not 100% sure what's going on there :-).

Thanks for the feedback.

@acmacalister
Copy link
Collaborator

Awesome. I don't think writePing is all that commonly used and I would like clean up the rest of the docs anyway so I think we are good. Thanks again!

acmacalister added a commit that referenced this pull request Mar 1, 2016
Adds an optional `writeCompletion` callback
@acmacalister acmacalister merged commit cf6def9 into daltoniam:master Mar 1, 2016
@lhecker
Copy link

lhecker commented Mar 31, 2016

@acmacalister Do you think it's feasable to release a new version with this feature soon?

@acmacalister
Copy link
Collaborator

@lhecker new release published (1.1.3) with this addition.

glennrfisher added a commit to watson-developer-cloud/swift-sdk that referenced this pull request Mar 31, 2016
@lhecker
Copy link

lhecker commented Apr 1, 2016

Thanks @acmacalister! This new feature is really useful to correctly handle backpressure. 😊

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