Skip to content

Commit

Permalink
rxjs dependency 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
code-yeongyu committed Feb 10, 2022
1 parent ff06666 commit 5d9ced6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 42 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
},
"dependencies": {
"axios": "^0.25.0",
"puppeteer": "^12.0.1",
"rxjs": "^7.5.2"
"puppeteer": "^12.0.1"
},
"devDependencies": {
"@babel/core": "^7.16.5",
Expand Down
29 changes: 1 addition & 28 deletions src/app/naver/service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import { PaymentHistory } from "app/common";
import { CommonResponse } from "app/common/types/response";
import {
concat,
defer,
distinctUntilChanged,
from,
interval,
mergeMap,
takeWhile,
} from "rxjs";
import { NaverModule } from ".";

export class NaverService {
Expand All @@ -23,28 +14,10 @@ export class NaverService {
this.cookies = await this.module.pageInteractor.getCookies();
}

interactiveLogin(id: string, password: string, delay?: number) {
const login$ = defer(() => from(this.normalLogin(id, password, delay)));
const loginStatus$ = interval(500)
.pipe(mergeMap(() => this.module.pageInteractor.getLoginStatus()))
.pipe(
distinctUntilChanged(),
takeWhile((loginStatus) => loginStatus !== "success")
);
const captchaStatus$ = interval(500)
.pipe(mergeMap(() => this.module.pageInteractor.getCaptchaStatus()))
.pipe(
distinctUntilChanged((a, b) => a?.question === b?.question),
takeWhile((captchaStatus) => captchaStatus !== null)
);

const result$ = concat(login$, captchaStatus$, loginStatus$);
return result$;
}

private async isResponseValid(response: CommonResponse) {
return response.status === 200;
}

private async getHistoryResult(response: CommonResponse) {
if (!this.isResponseValid(response)) {
throw new Error(`Invalid response: ${response.status} ${response.data}`);
Expand Down
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4215,13 +4215,6 @@ rxjs@^7.1.0:
dependencies:
tslib "~2.1.0"

rxjs@^7.5.2:
version "7.5.2"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.2.tgz#11e4a3a1dfad85dbf7fb6e33cbba17668497490b"
integrity sha512-PwDt186XaL3QN5qXj/H9DGyHhP3/RYYgZZwqBv9Tv8rsAaiwFH1IsJJlcgD37J7UW5a6O67qX0KWKS3/pu0m4w==
dependencies:
tslib "^2.1.0"

safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
Expand Down Expand Up @@ -4570,11 +4563,6 @@ tsc@^2.0.3:
resolved "https://registry.yarnpkg.com/tsc/-/tsc-2.0.3.tgz#037fe579e3bd67a5cbdaa604b43c6c1991b04bef"
integrity sha512-SN+9zBUtrpUcOpaUO7GjkEHgWtf22c7FKbKCA4e858eEM7Qz86rRDpgOU2lBIDf0fLCsEg65ms899UMUIB2+Ow==

tslib@^2.1.0:
version "2.3.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==

tslib@~2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
Expand Down

0 comments on commit 5d9ced6

Please sign in to comment.