Skip to content

Instantly share code, notes, and snippets.

@BjoernKW
Last active July 20, 2021 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BjoernKW/cdb055604f42ead4962032e3f151b73a to your computer and use it in GitHub Desktop.
Save BjoernKW/cdb055604f42ead4962032e3f151b73a to your computer and use it in GitHub Desktop.
Currying / partial functional application
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