Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Add unsubscribe example to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Hořák authored and Jakub Hořák committed Oct 31, 2018
1 parent f577221 commit b7dcfbe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ export class MyComponent {
@State() name: string;

changeName: Action;


private unsubscribe: () => void;

componentWillLoad() {
this.store.mapStateToProps(this, (state) => {
this.unsubscribe = this.store.mapStateToProps(this, (state) => {
const {
myReducer: { name }
} = state;
Expand All @@ -88,5 +90,9 @@ export class MyComponent {
doNameChange(newName: string) {
this.changeName(newName);
}

componentDidUnload() {
this.unsubscribe();
}
}
```

0 comments on commit b7dcfbe

Please sign in to comment.