WIP: Add custom event for path changes #34
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a custom event that fires any time the path changes.
I'm not sure if this is the kind of thing you want to have in the codebase so I thought I would start this PR as a kind of discussion.
For the thing I'm working on I thought it would be interesting to be able to view a game from both players' perspectives at the same time. For this to be useful would require the two boards to be in sync. Having a simple custom event like this allows me to achieve that with a simple event listener:
synced.boards.mov
At first I tried to do this by adding click event listeners to the back/forward arrows, but that doesn't account for keyboard nav or clicking on moves in the list, and they also got cleared out after opening the menu since I think the buttons get re-rendered.
Anyway, if this seems like an ok idea to you, I was thinking it might be best to include some kind of abstraction around it, especially since there are one or two other things I might like to keep track of (like board size).