File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change 1
- import { distinctUntilChanged , interval , mergeMap , takeWhile } from "rxjs" ;
1
+ import {
2
+ concat ,
3
+ defer ,
4
+ distinctUntilChanged ,
5
+ from ,
6
+ interval ,
7
+ mergeMap ,
8
+ takeWhile ,
9
+ } from "rxjs" ;
2
10
import { Module } from "." ;
3
11
4
12
export default class Service {
@@ -8,17 +16,22 @@ export default class Service {
8
16
this . module = module ;
9
17
}
10
18
11
- async login ( id : string , password : string ) {
19
+ async normalLogin ( id : string , password : string ) {
12
20
await this . module . urlChanger . moveToLoginURL ( ) ;
13
- this . module . pageInteractor . login ( id , password ) ;
21
+ await this . module . pageInteractor . login ( id , password ) ;
22
+ }
14
23
24
+ interactiveLogin ( id : string , password : string ) {
25
+ const login$ = defer ( ( ) => from ( this . normalLogin ( id , password ) ) ) ;
15
26
const loginStatus$ = interval ( 500 )
16
27
. pipe ( mergeMap ( ( ) => this . module . pageInteractor . getLoginStatus ( ) ) )
17
28
. pipe (
18
29
distinctUntilChanged ( ) ,
19
30
takeWhile ( ( loginStatus ) => loginStatus !== "success" )
20
31
) ;
21
- return loginStatus$ ;
32
+
33
+ const result$ = concat ( login$ , loginStatus$ ) ;
34
+ return result$ ;
22
35
}
23
36
24
37
async getHistory ( ) {
You can’t perform that action at this time.
0 commit comments