-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Adds an optional writeCompletion
callback
#178
Conversation
writeCompletion
callback
- parameter data: The data to write. | ||
- parameter completion: The (optional) completion handler. | ||
*/ | ||
public func writeData(data: NSData, completion: (() -> ())?) { |
There was a problem hiding this comment.
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.
Looks good! Other than that one comment, can we also add the completion closure to |
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. |
Awesome. I don't think |
Adds an optional `writeCompletion` callback
@acmacalister Do you think it's feasable to release a new version with this feature soon? |
@lhecker new release published (1.1.3) with this addition. |
These completion handlers were added with daltoniam/Starscream/pull/178, which was recently released with Starscream v1.1.3 (https://github.com/daltoniam/Starscream/releases/tag/1.1.3).
Thanks @acmacalister! This new feature is really useful to correctly handle backpressure. 😊 |
I often need to write files that I'm lazily reading out of an
NSInputStream
. The addition of awriteCompletion
callback to thewrite(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 :-)