My First Clean Architecture
This commit is contained in:
parent
4d4aaa2c4b
commit
bf7c125fb2
8 changed files with 185 additions and 3 deletions
14
src/background/domains/completion-group.js
Normal file
14
src/background/domains/completion-group.js
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
24
src/background/domains/completion-item.js
Normal file
24
src/background/domains/completion-item.js
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
27
src/background/domains/completions.js
Normal file
27
src/background/domains/completions.js
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
Reference in a new issue