1- import { Observable } from 'rxjs/Observable'
2- import { Subject } from 'rxjs/Subject'
1+ import { Subject , of } from 'rxjs'
32import PubSub from 'pubsub-js'
43
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'
1513
1614import { makeDebugger , isEmptyValue , EVENT } from '../../utils'
1715import {
@@ -37,24 +35,28 @@ export default class Pockect {
3735 this . stop$ = new Subject ( ) // esc, pageClick ...
3836 // TODO: netfix search use throttle
3937 // 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()
4139
4240 PubSub . subscribe ( EVENT . LOGIN_PANEL , ( ) => {
4341 this . store . handleLogin ( )
4442 this . input$ . next ( '/login/' )
4543 } )
4644
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+ )
5152
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+ )
5557
56- this . cmdSuggesttion$ = this . cmdSuggestionCommon . merge (
57- this . cmdSuggestionSpecial
58+ this . cmdSuggesttion$ = this . cmdSuggestionCommon . pipe (
59+ merge ( this . cmdSuggestionSpecial )
5860 )
5961 }
6062
@@ -75,6 +77,6 @@ export default class Pockect {
7577 }
7678
7779 emptyInput ( ) {
78- return this . input$ . filter ( isEmptyValue )
80+ return this . input$ . pipe ( filter ( isEmptyValue ) )
7981 }
8082}
0 commit comments