Skip to content

rename didReceivePart to didReceiveBodyPart #84

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

Merged
merged 2 commits into from
Aug 17, 2019

Conversation

artemredkin
Copy link
Collaborator

@artemredkin artemredkin commented Aug 17, 2019

fixes #83 (JW: I made this fixes instead of addresses because that's a magic word to github which will auto close #83 once this is merged).

@weissi
Copy link
Contributor

weissi commented Aug 17, 2019

@artemredkin thanks that looks great. I just have one proposal that we might want or not want.

The problem with this rename is that it'll break some people's code (which obviously is cool with the SemVer rules because we're 1.0.0-alpha.* still. However, we could put a temporary compatibility shim in there and remove it just before tagging 1.0.0.

What we could do is this

/// === code in async-http-client
protocol Delegate {
    func didReceiveBodyPart(_ fake: String)

    // PROBLEM: this deprecation warning will _NOT_ be shown to users implementing the protocol but rather will be shown when async-http-client calls it (see below)
    @available(*, deprecated, message: "didReceiveBodyPart(:)")
    func didReceivePart(_ fake: String)
}

extension Delegate {
    func func didReceivePart(_ fake: String) {}

    // this calls the old didReceivePart if the user didn't override the new one
    func didReceiveBodyPart(_ fake: String) {
        // PROBLEM: this will put a (temporary) compiler warning in the async-http-client code which isn't nice but maybe acceptable.
        self.didReceivePart(fake)
    }
}

// === user's code
struct Oldie: Delegate {
    func didReceivePart(_ fake: String) {
        print("did receive \(fake)")
    }
}

// this will work
Oldie().didReceiveBodyPart("body")

@ianpartridge / @Lukasa / @tanner0101 / @adtrevor / @t089 how important to we think it is to not break folks now?

@weissi
Copy link
Contributor

weissi commented Aug 17, 2019

UPDATE: Ignore my above comment, I did a github search and I couldn't find anyone implementing that. The only hits were false positives and async-http-client itself... So I think we can safely merge this.

Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

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

thank you, lgtm!

@artemredkin artemredkin merged commit e9d0dd2 into master Aug 17, 2019
@artemredkin artemredkin deleted the rename_body_part_callback branch August 17, 2019 12:32
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.

should we rename didReceivePart to didReceiveBodyPart ?
3 participants