diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-07-20 23:36:03 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-07-21 16:15:07 +0900 |
commit | bf7c125fb214b52d67527bdd292a4b5bb81b1d32 (patch) | |
tree | a491d7b17a6cee685f134c019a0d624d32e13a3a /src/background/domains | |
parent | 4d4aaa2c4ba9f09e23882287ce868c820aa900ee (diff) |
My First Clean Architecture
Diffstat (limited to 'src/background/domains')
-rw-r--r-- | src/background/domains/completion-group.js | 14 | ||||
-rw-r--r-- | src/background/domains/completion-item.js | 24 | ||||
-rw-r--r-- | src/background/domains/completions.js | 27 |
3 files changed, 65 insertions, 0 deletions
diff --git a/src/background/domains/completion-group.js b/src/background/domains/completion-group.js new file mode 100644 index 0000000..1749d72 --- /dev/null +++ b/src/background/domains/completion-group.js @@ -0,0 +1,14 @@ +export default class CompletionGroup { + constructor(name, items) { + this.name0 = name; + this.items0 = items; + } + + get name() { + return this.name0; + } + + get items() { + return this.items0; + } +} diff --git a/src/background/domains/completion-item.js b/src/background/domains/completion-item.js new file mode 100644 index 0000000..c7ad8a1 --- /dev/null +++ b/src/background/domains/completion-item.js @@ -0,0 +1,24 @@ +export default class CompletionItem { + constructor({ caption, content, url, icon }) { + this.caption0 = caption; + this.content0 = content; + this.url0 = url; + this.icon0 = icon; + } + + get caption() { + return this.caption0; + } + + get content() { + return this.content0; + } + + get url() { + return this.url0; + } + + get icon() { + return this.icon0; + } +} diff --git a/src/background/domains/completions.js b/src/background/domains/completions.js new file mode 100644 index 0000000..4e4219f --- /dev/null +++ b/src/background/domains/completions.js @@ -0,0 +1,27 @@ +export default class Completions { + constructor(groups) { + this.g = groups; + } + + get groups() { + return this.g; + } + + serialize() { + return this.groups.map(group => ({ + name: group.name, + items: group.items.map(item => ({ + caption: item.caption, + content: item.content, + url: item.url, + icon: item.icon, + })), + })); + } + + static EMPTY_COMPLETIONS = new Completions([]); + + static empty() { + return Completions.EMPTY_COMPLETIONS; + } +} |