Skip to content

Commit

Permalink
rename custom events
Browse files Browse the repository at this point in the history
  • Loading branch information
customcommander committed Sep 27, 2024
1 parent 41a91f3 commit ccec185
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
10 changes: 3 additions & 7 deletions src/component-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ class App extends LitElement {
mechanism for several other observables
so the emission needs to be multicasted.
TODO: rename `game.restart`
*/
this._restart$ = fromEvent(this, 'restart-game').pipe(
this._restart$ = fromEvent(this, 'game.restart').pipe(
map(() => true),
share()
);
Expand All @@ -102,7 +101,7 @@ class App extends LitElement {
1. From playing the game.
The player moves are dispatched through a dedicated
CustomEvent channel `player.move` (TODO: rename).
CustomEvent channel `player.move`.
This observable subscribes to that channel.
Expand All @@ -128,13 +127,10 @@ class App extends LitElement {
})
);

// TODO: rename to `player.move`.
// allow to unsubscribe from it.
fromEvent(this, 'dispatch')
fromEvent(this, 'player.move')
.pipe(map(ev => ev.detail))
.subscribe(this._event$);


/*
This emits only after a player has decided
Expand Down
2 changes: 1 addition & 1 deletion src/component-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Err extends LitElement {

_dismiss() {
this.dispatchEvent(
new CustomEvent('dispatch', {
new CustomEvent('player.move', {
bubbles: true,
composed: true,
detail: {
Expand Down
2 changes: 1 addition & 1 deletion src/component-farmyard.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class FarmYard extends LitElement {

_dispatch(sel) {
this.dispatchEvent(
new CustomEvent('dispatch', {
new CustomEvent('player.move', {
bubbles: true,
composed: true,
detail: sel
Expand Down
2 changes: 1 addition & 1 deletion src/component-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AgricolaFooter extends LitElement {

_restart() {
this.dispatchEvent(
new CustomEvent('restart-game', {
new CustomEvent('game.restart', {
bubbles: true,
composed: true
})
Expand Down
2 changes: 1 addition & 1 deletion src/component-infobar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class InfoBar extends LitElement {

_dispatch(task_id) {
this.dispatchEvent(
new CustomEvent('dispatch', {
new CustomEvent('player.move', {
bubbles: true,
composed: true,
detail: {
Expand Down
2 changes: 1 addition & 1 deletion src/component-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Tasks extends LitElement {

_notify(task_id) {
this.dispatchEvent(
new CustomEvent('dispatch', {
new CustomEvent('player.move', {
bubbles: true,
composed: true,
detail: {
Expand Down

0 comments on commit ccec185

Please sign in to comment.