Skip to content

Commit

Permalink
chore: unsubscribe subscription onDestroy
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Dec 5, 2017
1 parent 3ad981a commit 38245cb
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Then in HTML
For `ngModel` to work, You must import `FromsModule` from `@angular/forms`

### Documentation

Check [wiki][wiki] for more information

[npm]: https://www.npmjs.com/
Expand Down
2 changes: 1 addition & 1 deletion docs/3rdpartylicenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@angular/[email protected].0
@angular/[email protected].3
MIT
MIT
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>NgxEditor</title><base href="ngx-editor"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><link href="styles.3ccbe96a5a764c24870d.bundle.css" rel="stylesheet"/></head><body><app-root></app-root><script async defer="defer" src="https://buttons.github.io/buttons.js"></script><script type="text/javascript" src="inline.90775b056b82a9127190.bundle.js"></script><script type="text/javascript" src="polyfills.ad37cd45a71cb38eee76.bundle.js"></script><script type="text/javascript" src="main.4dfced48e5839ada9fe7.bundle.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>NgxEditor</title><base href="ngx-editor"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><link href="styles.3ccbe96a5a764c24870d.bundle.css" rel="stylesheet"/></head><body><app-root></app-root><script async defer="defer" src="https://buttons.github.io/buttons.js"></script><script type="text/javascript" src="inline.dd8a541cfbc7a0565666.bundle.js"></script><script type="text/javascript" src="polyfills.ad37cd45a71cb38eee76.bundle.js"></script><script type="text/javascript" src="main.f4002c6365bd7516a919.bundle.js"></script></body></html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/main.4dfced48e5839ada9fe7.bundle.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/main.f4002c6365bd7516a919.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/polyfills.ad37cd45a71cb38eee76.bundle.js

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { AppService } from './app.service';
import { Subject } from 'rxjs/Subject';

@Component({
selector: 'app-root',
Expand All @@ -8,9 +9,11 @@ import { AppService } from './app.service';
providers: [AppService]
})

export class AppComponent implements OnInit {
export class AppComponent implements OnInit, OnDestroy {

title = 'ngx-editor';
latestRelease: any = {};
private subscription: Subject<any> = new Subject();

editorConfig = {
editable: true,
Expand All @@ -26,16 +29,20 @@ export class AppComponent implements OnInit {
constructor(private _appService: AppService) { }

getLatestRelease() {
this._appService.getLatestRelease().subscribe(
this.subscription = this._appService.getLatestRelease().subscribe(
data => this.latestRelease = data,
error => { console.log(error); },
() => {
// console.log('latest release: ' + this.latestRelease['name']);
console.log('latest release: ' + this.latestRelease['name']);
});
}

ngOnInit() {
this.getLatestRelease();
}

ngOnDestroy() {
this.subscription.unsubscribe();
}

}
4 changes: 2 additions & 2 deletions src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export class AppService {

constructor(private _http: HttpClient) { }

getLatestRelease() {
getLatestRelease(): any {

return this._http.get(this.releaseURL)
.map((response) => {
.map((response: any) => {
if (response && response['length'] !== 0) {
return response;
} else {
Expand Down

0 comments on commit 38245cb

Please sign in to comment.