File tree Expand file tree Collapse file tree 3 files changed +44
-35
lines changed Expand file tree Collapse file tree 3 files changed +44
-35
lines changed Original file line number Diff line number Diff line change 1
- import { Operator } from '../Operator' ;
2
- import { Subscriber } from '../Subscriber' ;
1
+
3
2
import { Observable } from '../Observable' ;
3
+ import { isEmpty as higherOrder } from '../operators' ;
4
4
5
5
/**
6
6
* If the source Observable is empty it returns an Observable that emits true, otherwise it emits false.
@@ -12,37 +12,5 @@ import { Observable } from '../Observable';
12
12
* @owner Observable
13
13
*/
14
14
export function isEmpty < T > ( this : Observable < T > ) : Observable < boolean > {
15
- return this . lift ( new IsEmptyOperator ( ) ) ;
16
- }
17
-
18
- class IsEmptyOperator implements Operator < any , boolean > {
19
- call ( observer : Subscriber < boolean > , source : any ) : any {
20
- return source . subscribe ( new IsEmptySubscriber ( observer ) ) ;
21
- }
22
- }
23
-
24
- /**
25
- * We need this JSDoc comment for affecting ESDoc.
26
- * @ignore
27
- * @extends {Ignored }
28
- */
29
- class IsEmptySubscriber extends Subscriber < any > {
30
- constructor ( destination : Subscriber < boolean > ) {
31
- super ( destination ) ;
32
- }
33
-
34
- private notifyComplete ( isEmpty : boolean ) : void {
35
- const destination = this . destination ;
36
-
37
- destination . next ( isEmpty ) ;
38
- destination . complete ( ) ;
39
- }
40
-
41
- protected _next ( value : boolean ) {
42
- this . notifyComplete ( false ) ;
43
- }
44
-
45
- protected _complete ( ) {
46
- this . notifyComplete ( true ) ;
47
- }
15
+ return higherOrder ( ) ( this ) ;
48
16
}
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ export { findIndex } from './findIndex';
31
31
export { first } from './first' ;
32
32
export { groupBy } from './groupBy' ;
33
33
export { ignoreElements } from './ignoreElements' ;
34
+ export { isEmpty } from './isEmpty' ;
34
35
export { map } from './map' ;
35
36
export { materialize } from './materialize' ;
36
37
export { max } from './max' ;
Original file line number Diff line number Diff line change
1
+ import { Operator } from '../Operator' ;
2
+ import { Subscriber } from '../Subscriber' ;
3
+ import { Observable } from '../Observable' ;
4
+ import { OperatorFunction } from '../interfaces' ;
5
+
6
+ export function isEmpty < T > ( ) : OperatorFunction < T , boolean > {
7
+ return ( source : Observable < T > ) => source . lift ( new IsEmptyOperator ( ) ) ;
8
+ }
9
+
10
+ class IsEmptyOperator implements Operator < any , boolean > {
11
+ call ( observer : Subscriber < boolean > , source : any ) : any {
12
+ return source . subscribe ( new IsEmptySubscriber ( observer ) ) ;
13
+ }
14
+ }
15
+
16
+ /**
17
+ * We need this JSDoc comment for affecting ESDoc.
18
+ * @ignore
19
+ * @extends {Ignored }
20
+ */
21
+ class IsEmptySubscriber extends Subscriber < any > {
22
+ constructor ( destination : Subscriber < boolean > ) {
23
+ super ( destination ) ;
24
+ }
25
+
26
+ private notifyComplete ( isEmpty : boolean ) : void {
27
+ const destination = this . destination ;
28
+
29
+ destination . next ( isEmpty ) ;
30
+ destination . complete ( ) ;
31
+ }
32
+
33
+ protected _next ( value : boolean ) {
34
+ this . notifyComplete ( false ) ;
35
+ }
36
+
37
+ protected _complete ( ) {
38
+ this . notifyComplete ( true ) ;
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments