My First Clean Architecture

This commit is contained in:
Shin'ya Ueoka 2018-07-20 23:36:03 +09:00
parent 4d4aaa2c4b
commit bf7c125fb2
8 changed files with 185 additions and 3 deletions

View 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;
}
}

View 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;
}
}

View 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;
}
}