Skip to content

Commit

Permalink
🧪 improve playground by adding an examples abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Jun 6, 2024
1 parent 2c324c0 commit 14e1af8
Show file tree
Hide file tree
Showing 2 changed files with 311 additions and 217 deletions.
29 changes: 29 additions & 0 deletions playground/examples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Examples {
#examples: Function[] = [];
#only: Function[] = [];

constructor() {
window.addEventListener(
"load",
() => {
if (this.#only.length > 0) {
this.#only.forEach((fn) => fn());
} else {
this.#examples.forEach((fn) => fn());
}
},
{ once: true },
);
}

make(fn: () => void): void {
this.#examples.push(fn);
}

only(fn: () => void): void {
this.#only.push(fn);
}
}

const examples = new Examples();
export default examples;
Loading

0 comments on commit 14e1af8

Please sign in to comment.