30 lines
588 B
TypeScript
30 lines
588 B
TypeScript
export class Todo {
|
|
public readonly id: string;
|
|
protected content: string;
|
|
|
|
public constructor(content: string, private completed?: boolean) {
|
|
this.id = crypto.randomUUID();
|
|
this.content = content;
|
|
}
|
|
|
|
// public markAsCompleted() {
|
|
// this.completed = true;
|
|
// }
|
|
|
|
// protected setContent(content: string) {
|
|
// this.content = content;
|
|
// }
|
|
}
|
|
|
|
const todos: Todo[] = [];
|
|
|
|
export function createTodo(content: string): Todo {
|
|
const newTodo = new Todo(content);
|
|
todos.push(newTodo);
|
|
return newTodo;
|
|
}
|
|
|
|
export function getTodos(): Todo[] {
|
|
return todos;
|
|
}
|