Mouse Event Kata

mouse-event-kata

Esta kata es parte del libro Código sostenible.

Test-drive the methods missing the implementation:

public class Mouse {
  private List<MouseEventListener> listeners = new ArrayList<>();
  private final long timeWindowInMillisecondsForDoubleClick = 500;

  public void pressLeftButton(long currentTimeInMilliseconds) {
      /*... implement this method ...*/
  }

  public void releaseLeftButton(long currentTimeInMilliseconds) {
      /*... implement this method ...*/
  }

  public void move(MousePointerCoordinates from, MousePointerCoordinates to, long currentTimeInMilliseconds) {
      /*... implement this method ...*/
  }

  public void subscribe(MouseEventListener listener) {
      listeners.add(listener);
  }

  private void notifySubscribers(MouseEventType eventType) {
      listeners.forEach(listener -> listener.handleMouseEvent(eventType));
  }
}

  • TypeScript

    Solución con TypeScript v1