Created
September 17, 2018 06:21
-
-
Save georgebyte/b64528770dd1bfde37acfa11817848e4 to your computer and use it in GitHub Desktop.
Observable store fetch data "side effect"
This file contains hidden or 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
loadData() { | |
this.setState({ | |
...this.state, | |
requestInProgress: true, | |
}); | |
return this.http.get(url).pipe( | |
tap(data => { | |
this.setState({ | |
...this.state, | |
data: data, | |
requestInProgress: false, | |
}); | |
}), | |
catchError(error => { | |
this.setState({ | |
...this.state, | |
error: error, | |
requestInProgress: false, | |
}); | |
return throwError(error); | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment