-
-
Save BjoernKW/cdb055604f42ead4962032e3f151b73a to your computer and use it in GitHub Desktop.
Currying / partial functional application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private executeUpdate(httpHeaders: HttpHeaders, afterSuccessfulUpdate = () => { | |
}) { | |
this.handleError(error, httpHeaders, (callbackHttpHeaders: HttpHeaders) => { | |
this.executeUpdate(callbackHttpHeaders).pipe(first()).subscribe(afterSuccessfulUpdate); | |
}); | |
} | |
private handleError(error: Error, httpHeaders: HttpHeaders, callback: Function) { | |
if (error.status === 412) { | |
let httpHeadersWithConfirmation = new HttpHeaders(); | |
for (const headerKey of httpHeaders.keys()) { | |
httpHeadersWithConfirmation = httpHeadersWithConfirmation.append(headerKey, httpHeaders.get(headerKey)); | |
} | |
httpHeadersWithConfirmation = httpHeadersWithConfirmation.append('confirmed', 'true'); | |
this.openErrorDialog(error, () => callback(httpHeadersWithConfirmation)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment