Skip to content

Commit

Permalink
record all events emitted by the player
Browse files Browse the repository at this point in the history
  • Loading branch information
customcommander committed Sep 8, 2024
1 parent e259c2b commit bdb600f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/component-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class App extends LitElement {
#tasks;
#turn;

// All events emitted by the player.
#log = [];

constructor() {
super();

Expand Down Expand Up @@ -112,14 +115,14 @@ class App extends LitElement {
observe(tasks$, tasks => this.#tasks.setValue(tasks));
observe(turn$, turn => this.#turn.setValue(turn));

this.addEventListener('dispatch', (e) => this.#game.send(e.detail));
this.addEventListener('dispatch', (e) => {
this.#log.push({$version: VERSION, ...e.detail});
this.#game.send(e.detail);
});
}

connectedCallback() {
super.connectedCallback();
this.#game.subscribe(snap => {
console.log(snap.value);
});
this.#game.start();
}

Expand Down

0 comments on commit bdb600f

Please sign in to comment.