-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kmathy-feature/rxjs-6-support-new-imports'
- Loading branch information
Showing
6 changed files
with
6,611 additions
and
480 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
## Usage | ||
|
||
### Rxjs 5.5+ (pipeable operators) | ||
### RxJS 6+ | ||
```ts | ||
import { Component, OnInit, OnDestroy } from '@angular/core'; | ||
import { TakeUntilDestroy, untilDestroyed } from 'ngx-take-until-destroy'; | ||
|
@@ -39,41 +39,9 @@ export class InboxComponent implements OnInit, OnDestroy { | |
} | ||
``` | ||
|
||
### Pre [email protected] (or if you're still patching the observable prototype) | ||
```ts | ||
import { Component, OnInit } from '@angular/core'; | ||
import { TakeUntilDestroy, OnDestroy } from 'ngx-take-until-destroy'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import 'rxjs/add/observable/interval'; | ||
import 'rxjs/add/operators/takeUntil'; | ||
|
||
@TakeUntilDestroy() | ||
@Component({ | ||
selector: 'app-inbox', | ||
templateUrl: './inbox.component.html' | ||
}) | ||
export class InboxComponent implements OnInit, OnDestroy { | ||
readonly destroyed$: Observable<boolean>; | ||
|
||
ngOnInit( ) { | ||
Observable.interval(1000) | ||
.takeUntil(this.destroyed$) | ||
.subscribe(val => console.log(val)) | ||
} | ||
|
||
// If you work with AOT this method must be present, even if empty! | ||
// Otherwise 'ng build --prod' will optimize away any calls to ngOnDestroy, | ||
// even if the method is added by the @TakeUntilDestroy decorator | ||
ngOnDestroy() { | ||
// You can also do whatever you need here | ||
} | ||
|
||
} | ||
``` | ||
|
||
### Use with any class | ||
|
||
#### Rxjs 5.5+ (pipeable operators) | ||
#### RxJS 6+ | ||
```ts | ||
import { TakeUntilDestroy, untilDestroyed } from 'ngx-take-until-destroy'; | ||
import { interval } from 'rxjs/Observable/interval'; | ||
|
@@ -92,28 +60,3 @@ export class Widget { | |
|
||
} | ||
``` | ||
|
||
#### Before [email protected] (or if you're still patching the observable prototype) | ||
```ts | ||
import { TakeUntilDestroy } from 'ngx-take-until-destroy'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import 'rxjs/add/observable/interval'; | ||
import 'rxjs/add/operators/takeUntil'; | ||
|
||
@TakeUntilDestroy('destroy') | ||
export class Widget { | ||
readonly destroyed$: Observable<boolean>; | ||
|
||
constructor( ) { | ||
Observable.interval(1000) | ||
.takeUntil(this.destroyed$) | ||
.subscribe(console.log) | ||
} | ||
|
||
// The name needs to be the same as the decorator parameter | ||
destroy() { | ||
} | ||
|
||
} | ||
``` | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +0,0 @@ | ||
{ | ||
"name": "ngx-take-until-destroy", | ||
"version": "2.2.1", | ||
"main": "dist/index.js", | ||
"module": "dist/es5/index.js", | ||
"es2015": "dist/index.js", | ||
"description": "Class decorator that adds takeUntil component destroyed", | ||
"license": "MIT", | ||
"scripts": { | ||
"clearDist": "rm -rf ./dist", | ||
"clear": "npm run clearDist", | ||
"compile": "tsc --p tsconfig.es5.json && tsc --p tsconfig.es2015.json && tsc --p tsconfig.umd.json", | ||
"precompile": "npm run clearDist", | ||
"prepublish": "npm test && clear && npm run compile", | ||
"test": "jest" | ||
}, | ||
"typings": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"maintainers": [ | ||
"Netanel Basal" | ||
], | ||
"repository": { | ||
"url": "https://github.com/NetanelBasal/ngx-take-until-destroy" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"js" | ||
], | ||
"transform": { | ||
"\\.(ts)$": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
}, | ||
"testRegex": "/__tests__/.*\\.(ts|js)$" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^22.0.1", | ||
"jest": "^22.0.5", | ||
"rxjs": "^5.5.0", | ||
"ts-jest": "^22.0.1", | ||
"typescript": "^2.6.1" | ||
} | ||
} | ||
This file contains 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
Oops, something went wrong.