Add skeleton for file event handling

This commit is contained in:
Andras Schmelczer 2024-12-08 10:58:03 +00:00
parent 1420cf104e
commit 8a7cc65e88
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
6 changed files with 259 additions and 4 deletions

View file

@ -0,0 +1,42 @@
import { ItemView, WorkspaceLeaf } from "obsidian";
import { Logger } from "src/logger";
export class SyncView extends ItemView {
public static TYPE = "example-view";
constructor(leaf: WorkspaceLeaf) {
super(leaf);
}
getViewType() {
return SyncView.TYPE;
}
getDisplayText() {
return "Example view";
}
async onOpen() {
const container = this.containerEl.children[1];
container.empty();
container.createEl("h4", { text: "Example view" });
setInterval(() => this.updateView(), 1000);
}
async updateView() {
const container = this.containerEl.children[1];
container.empty();
const messages = Logger.getInstance()
.getMessages()
.map((message) => message.toString())
.join("\n");
container.createEl("pre", { text: messages });
}
async onClose() {
// Nothing to clean up.
}
}