Skip to content

Instantly share code, notes, and snippets.

@pascalwhoop
Last active March 17, 2017 10:52
Show Gist options
  • Save pascalwhoop/006ca7d3d5c4e6d20126b0de43597088 to your computer and use it in GitHub Desktop.
Save pascalwhoop/006ca7d3d5c4e6d20126b0de43597088 to your computer and use it in GitHub Desktop.
public orderPost(offerId: string, takeaway: boolean): Observable<Order> {
//http call prep code ...
//...
let obs = this.http.post(path, orderBooking, requestOptions)
.map((response: Response) => {
if (response.status === 204) {
return undefined;
} else {
return response.json();
}
})
.publish(); //ensuring we only have one subscription to pass around, otherwise you get multiple http calls every time
obs.connect();
//here we tell the feedback service what we want. we'd like spinning and toasting
this.vfeedback.showMessageOnAnswer('Order placed!', 'Oops', obs);
this.vfeedback.spinUntilCompleted(obs);
return obs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment