mliebelt / pgn-viewer

Simple PGN viewer with the necessary features to display chess games
GNU General Public License v3.0
161 stars 44 forks source link

Public base.stop() function to stop the timer #492

Closed Bebul closed 8 months ago

Bebul commented 8 months ago

Problem statement

When html is created programatically with boards having the same id, it may happen there was some timer running, calling nextMove again and again.

Problem ilustrates the video, where it swaps to different tournament, the board changes but the timer is running and still selects some HTML elements based on boardId etc.

https://github.com/mliebelt/pgn-viewer/assets/9265147/3f7493db-6812-49b1-97f8-b2d5f9651c9b

Solution

It is necessary to be able to stop it on demand programatically.

mliebelt commented 8 months ago

Ok, understand the idea. This may change in the future, but it will be possibly part of the (needed) public API of the viewer. #175

Bebul commented 8 months ago

Ok, understand the idea. This may change in the future, but it will be possibly part of the (needed) public API of the viewer. #175

Thank you for fast response.

Yes, it was first thing I was checking, the

I think, it can be a problem to change the API after more people use it. Then forcing more people to fix their code using it.

So, maybe, the #175 should at least progress in some structural proposal, so any new API functions would be well placed.

mliebelt commented 8 months ago

The idea I have in mind is to do a 2 step process:

  1. Develop a new API in parallel to the (half-way) existing one. So the old usage is allowed, but the new usage will be possible as well.
  2. In some future version, the old API will be made (perhaps) deprecated, so the old code may be removed later on.

I think most of the people that use the viewer use it as it is, they will hopefully never see a change in functionality. Only if you want to have a deep integration, with using additional API calls, you will be forced to switch to the new API then.

Bebul commented 8 months ago

I think most of the people that use the viewer use it as it is, they will hopefully never see a change in functionality.

You are probably right. Also, one can always stick to older version if new one has raised its major version and is not backward compatible.

Having it somewhere in parallel looks good.

Bebul commented 8 months ago

If I add some new API calls, I will establish something in parallel, it can be named something like wip for work in progress to emphasize it is subject to be changed in the (near) future.