1
- import { Observable } from 'rxjs/Observable'
2
- import { Subject } from 'rxjs/Subject'
1
+ import { Subject , of } from 'rxjs'
3
2
import PubSub from 'pubsub-js'
4
3
5
- // import 'rxjs/add/observable/of'
6
- import 'rxjs/add/operator/do'
7
- import 'rxjs/add/operator/catch'
8
- import 'rxjs/add/operator/switchMap'
9
- import 'rxjs/add/operator/debounceTime'
10
- import 'rxjs/add/operator/takeUntil'
11
- // import 'rxjs/add/operator/distinctUntilChanged'
12
- import 'rxjs/add/operator/map'
13
- import 'rxjs/add/operator/filter'
14
- import 'rxjs/add/operator/merge'
4
+ import {
5
+ catchError ,
6
+ switchMap ,
7
+ debounceTime ,
8
+ takeUntil ,
9
+ map ,
10
+ filter ,
11
+ merge ,
12
+ } from 'rxjs/operators'
15
13
16
14
import { makeDebugger , isEmptyValue , EVENT } from '../../utils'
17
15
import {
@@ -37,24 +35,28 @@ export default class Pockect {
37
35
this . stop$ = new Subject ( ) // esc, pageClick ...
38
36
// TODO: netfix search use throttle
39
37
// see: https://www.youtube.com/watch?v=XRYN2xt11Ek
40
- this . cmdInput$ = this . input$ . debounceTime ( 200 ) // .distinctUntilChanged()
38
+ this . cmdInput$ = this . input$ . pipe ( debounceTime ( 200 ) ) // .distinctUntilChanged()
41
39
42
40
PubSub . subscribe ( EVENT . LOGIN_PANEL , ( ) => {
43
41
this . store . handleLogin ( )
44
42
this . input$ . next ( '/login/' )
45
43
} )
46
44
47
- this . cmdSuggestionCommon = this . cmdInput$
48
- . filter ( startWithSlash )
49
- . switchMap ( q => this . advisor . relateSuggestions$ ( q ) . takeUntil ( this . stop$ ) )
50
- . catch ( ( ) => Observable . of ( [ ] ) )
45
+ this . cmdSuggestionCommon = this . cmdInput$ . pipe (
46
+ filter ( startWithSlash ) ,
47
+ switchMap ( q =>
48
+ this . advisor . relateSuggestions$ ( q ) . pipe ( takeUntil ( this . stop$ ) )
49
+ ) ,
50
+ catchError ( ( ) => of ( [ ] ) )
51
+ )
51
52
52
- this . cmdSuggestionSpecial = this . cmdInput$
53
- . filter ( startWithSpecialPrefix ) // > < ?
54
- . map ( this . advisor . specialSuggestions )
53
+ this . cmdSuggestionSpecial = this . cmdInput$ . pipe (
54
+ filter ( startWithSpecialPrefix ) ,
55
+ map ( this . advisor . specialSuggestions )
56
+ )
55
57
56
- this . cmdSuggesttion$ = this . cmdSuggestionCommon . merge (
57
- this . cmdSuggestionSpecial
58
+ this . cmdSuggesttion$ = this . cmdSuggestionCommon . pipe (
59
+ merge ( this . cmdSuggestionSpecial )
58
60
)
59
61
}
60
62
@@ -75,6 +77,6 @@ export default class Pockect {
75
77
}
76
78
77
79
emptyInput ( ) {
78
- return this . input$ . filter ( isEmptyValue )
80
+ return this . input$ . pipe ( filter ( isEmptyValue ) )
79
81
}
80
82
}