diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-22 20:16:21 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 20:16:21 +0900 |
commit | c1f64927b63d18048790abd3ba907083dbca3084 (patch) | |
tree | 3a64b677763f62094c49527d8182f8756a52fbd1 /src/background/repositories | |
parent | ced89134e32d793d8e091113cfb20867e1c3b572 (diff) | |
parent | 7be8bc71784b8dedd0fee03dd72dd8936e2f3929 (diff) |
Merge pull request #588 from ueokande/tsyringe
Use tsyringe for DI container
Diffstat (limited to 'src/background/repositories')
7 files changed, 16 insertions, 0 deletions
diff --git a/src/background/repositories/BookmarkRepository.ts b/src/background/repositories/BookmarkRepository.ts index b4da509..d266ae6 100644 --- a/src/background/repositories/BookmarkRepository.ts +++ b/src/background/repositories/BookmarkRepository.ts @@ -1,3 +1,6 @@ +import { injectable } from 'tsyringe'; + +@injectable() export default class BookmarkRepository { async create( title: string, url: string diff --git a/src/background/repositories/BrowserSettingRepository.ts b/src/background/repositories/BrowserSettingRepository.ts index 33b35dd..9cfb35e 100644 --- a/src/background/repositories/BrowserSettingRepository.ts +++ b/src/background/repositories/BrowserSettingRepository.ts @@ -1,3 +1,4 @@ +import { injectable } from 'tsyringe'; import * as urls from '../../shared/urls'; declare namespace browser.browserSettings.homepageOverride { @@ -16,6 +17,7 @@ declare namespace browser.browserSettings.homepageOverride { function get(param: object): Promise<BrowserSettings>; } +@injectable() export default class BrowserSettingRepository { async getHomepageUrls(): Promise<string[]> { let { value } = await browser.browserSettings.homepageOverride.get({}); diff --git a/src/background/repositories/CompletionsRepository.ts b/src/background/repositories/CompletionsRepository.ts index 18af587..dfdbc27 100644 --- a/src/background/repositories/CompletionsRepository.ts +++ b/src/background/repositories/CompletionsRepository.ts @@ -1,6 +1,9 @@ +import { injectable } from 'tsyringe'; + type Tab = browser.tabs.Tab; type BookmarkTreeNode = browser.bookmarks.BookmarkTreeNode; +@injectable() export default class CompletionsRepository { async queryBookmarks(keywords: string): Promise<BookmarkTreeNode[]> { let items = await browser.bookmarks.search({ query: keywords }); diff --git a/src/background/repositories/FindRepository.ts b/src/background/repositories/FindRepository.ts index bf286e6..6a087f5 100644 --- a/src/background/repositories/FindRepository.ts +++ b/src/background/repositories/FindRepository.ts @@ -1,7 +1,9 @@ +import { injectable } from 'tsyringe'; import MemoryStorage from '../infrastructures/MemoryStorage'; const FIND_KEYWORD_KEY = 'find-keyword'; +@injectable() export default class FindRepository { private cache: MemoryStorage; diff --git a/src/background/repositories/MarkRepository.ts b/src/background/repositories/MarkRepository.ts index 69c85f6..c106fff 100644 --- a/src/background/repositories/MarkRepository.ts +++ b/src/background/repositories/MarkRepository.ts @@ -1,8 +1,10 @@ +import { injectable } from 'tsyringe'; import MemoryStorage from '../infrastructures/MemoryStorage'; import GlobalMark from '../domains/GlobalMark'; const MARK_KEY = 'mark'; +@injectable() export default class MarkRepository { private cache: MemoryStorage; diff --git a/src/background/repositories/PersistentSettingRepository.ts b/src/background/repositories/PersistentSettingRepository.ts index ff882a5..927bce9 100644 --- a/src/background/repositories/PersistentSettingRepository.ts +++ b/src/background/repositories/PersistentSettingRepository.ts @@ -1,5 +1,7 @@ +import { injectable } from 'tsyringe'; import SettingData from '../../shared/SettingData'; +@injectable() export default class SettingRepository { async load(): Promise<SettingData | null> { let { settings } = await browser.storage.local.get('settings'); diff --git a/src/background/repositories/SettingRepository.ts b/src/background/repositories/SettingRepository.ts index eb83a2c..2f159e5 100644 --- a/src/background/repositories/SettingRepository.ts +++ b/src/background/repositories/SettingRepository.ts @@ -1,9 +1,11 @@ +import { injectable } from 'tsyringe'; import MemoryStorage from '../infrastructures/MemoryStorage'; import Settings from '../../shared/Settings'; import * as PropertyDefs from '../../shared/property-defs'; const CACHED_SETTING_KEY = 'setting'; +@injectable() export default class SettingRepository { private cache: MemoryStorage; |