-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: component と usecase が参照する store を DeprecatedArticleStore から…
… ArticleStore に変更
- Loading branch information
Showing
4 changed files
with
17 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { inject, Injectable } from '@angular/core'; | ||
import { firstValueFrom } from 'rxjs'; | ||
import XMLParser from 'xml2js'; | ||
import { DeprecatedArticleStore } from '../containers/articles/article.store'; | ||
import { ArticleStore } from '../containers/articles/article.store'; | ||
import { FeedValueObject, RssFeed } from '../domain/feed'; | ||
import { FeedGateway } from '../infrastructures/gateways/feed.gateway'; | ||
|
||
@Injectable() | ||
export class ArticleUsecase { | ||
constructor( | ||
private readonly componentStore: DeprecatedArticleStore, | ||
private readonly feedGateway: FeedGateway, | ||
) {} | ||
private readonly store = inject(ArticleStore); | ||
private readonly feedGateway = inject(FeedGateway); | ||
|
||
async fetchFeed() { | ||
const rssFeed = await firstValueFrom(this.feedGateway.getRssResponse()); | ||
const parsed: RssFeed = await XMLParser.parseStringPromise(rssFeed); | ||
const feedValueObject = FeedValueObject.createFromRssResponse(parsed); | ||
|
||
this.componentStore.setFeed(feedValueObject.plainObject()); | ||
this.store.setFeed(feedValueObject.plainObject()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 9 additions & 10 deletions
19
src/app/features/blog/containers/articles/articles.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters