Skip to content

Commit 691f21e

Browse files
committed
interactiveLogin 메소드 추가
1 parent d9d43b3 commit 691f21e

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/app/naver/service.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
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";
210
import { Module } from ".";
311

412
export default class Service {
@@ -8,17 +16,22 @@ export default class Service {
816
this.module = module;
917
}
1018

11-
async login(id: string, password: string) {
19+
async normalLogin(id: string, password: string) {
1220
await this.module.urlChanger.moveToLoginURL();
13-
this.module.pageInteractor.login(id, password);
21+
await this.module.pageInteractor.login(id, password);
22+
}
1423

24+
interactiveLogin(id: string, password: string) {
25+
const login$ = defer(() => from(this.normalLogin(id, password)));
1526
const loginStatus$ = interval(500)
1627
.pipe(mergeMap(() => this.module.pageInteractor.getLoginStatus()))
1728
.pipe(
1829
distinctUntilChanged(),
1930
takeWhile((loginStatus) => loginStatus !== "success")
2031
);
21-
return loginStatus$;
32+
33+
const result$ = concat(login$, loginStatus$);
34+
return result$;
2235
}
2336

2437
async getHistory() {

0 commit comments

Comments
 (0)