DEV Community

Cover image for Day 6 - 100 days of Coding - Vs Code Extension - add restart feature
Ganesh Raja
Ganesh Raja

Posted on

2

Day 6 - 100 days of Coding - Vs Code Extension - add restart feature

So it's day 6 of 100 days of coding

Today's Objectives

1)Add Restart Functionality

2)Update the Format of the Data

Add Restart Functionality

To do this, I added a new command that will call the storeDate Method to make sure it stores the Data into File if it's a restarting Pomodoro.
Then it resets the value to default. Later it moves to the Start Timer Method to trigger new Pomodoro

  restartTimer() {
    if (this.tick >= 0) this.storeStatusToFile(); //Update File with Previous Pomodo Data
    this.resetPomodoTimer();
    this.startTimer();
  }
Enter fullscreen mode Exit fullscreen mode

Update the Format of the Data

Here we store the ISO String of Date & time the Pomodoro was started. If it's fully completed. We trigger completed. Else store as canceled


  storeStatusToFile() {
    let status = this.tick <= 0 && this.currentAction == POMODO_TIMER ? COMPLETED : CANCELED;
    let data = [this.startedTime.toISOString(), status].join(",");
    fs.appendFile(this.fileName, data + "\n", (err) => console.log(err));
  }
Enter fullscreen mode Exit fullscreen mode

Tomorrow I will be working on custom values for the PomodoTimer.

You can check the full code in my repo simple-pomodoro-timer

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more