Skip to content

Instantly share code, notes, and snippets.

const Task = class {
constructor() {
this._list = [];
}
add(task) {
this._list.push(task);
}
remove(task) {
const Task = class {
constructor() {
this._list = [];
}
add(task) {
if (!(task instanceof Task)) throw 'invalid Task';
this._list.push(task);
}
const Task = class {
constructor() {
this._list = [];
}
add(task) {
if (!(task instanceof Task)) throw 'invalid Task';
this._list.push(task);
}
const Task = class {
constructor(title, date) {
if (!title) throw 'invalid title';
this._title = title;
this._date = date;
this._isComplete = false;
this._list = [];
}
const Task = class {
constructor(title, date) {
if (!title) throw 'invalid title';
this._title = title;
this._date = date;
this._isComplete = false;
}
isComplete() {
<html><head></head><body>
<section id="todo"></section>
<script>
const TaskState = class {
static addState(key, cls) {
const v = new cls();
if (!(v instanceof TaskState)) throw 'invalid cls';
if ((TaskState._subClasses || (TaskState._subClasses = new Map())).has(key)) throw 'exist key';
TaskState._subClasses.set(key, cls);
}
<html><head></head><body>
<section id="todo"></section>
<script>
const TaskState = class {
static addState(key, cls) {
const v = new cls();
if (!(v instanceof TaskState)) throw 'invalid cls';
if ((TaskState._subClasses || (TaskState._subClasses = new Map())).has(key)) throw 'exist key';
TaskState._subClasses.set(key, cls);
}
<html><head></head><body>
<section id="todo"></section>
<script>
const TaskState = class {
static addState(key, cls) {
const v = new cls();
if (!(v instanceof TaskState)) throw 'invalid cls';
if ((TaskState._subClasses || (TaskState._subClasses = new Map())).has(key)) throw 'exist key';
TaskState._subClasses.set(key, cls);
}
<html><head></head><body>
<section id="todo"></section>
<script>
const Listener = class {
listen(type) {
throw 'must be overrided';
}
};
const Task = class extends Listener {
constructor() {
<html><head></head><body>
<section id="todo"></section>
<script>
const Task = class {
constructor() {
this._list = [];
}
add(task) {
this._list.push(task);
}