Day 4 - 100 days of Coding - Vs Code Extension - Store Date in a permanent file
Ganesh Raja
Posted on April 12, 2020
So it's day 4 of 100 days of coding
Today's Objectives
1)Add Pause Functionality for Rest Timer
2)Store Completed Pomodo into permanent file
I managed to complete the both the objective for today
Add Pause Functionality for Rest Timer
To Achieve this I had to Either add a new Command or adjust existing command. I decided to go with the existing command. So whenever startPomodoTimer is executed, it will check for current Action State, if it is Pomodoro Timer it will trigger start Work Timer or it will trigger rest Timer.
if (this.currentAction == POMODO_TIMER) this.startWorkTimer();
else this.startRestTimer();
Store Completed Pomodo into permanent file
To achieve this I had to use Vscode Context. There is a path allocated for all the plugins. To make sure our specific directory exist we need to make sure using fs module of node.
try {
fs.mkdirSync(context.globalStoragePath, { recursive: true });
} catch (exception) {
console.log(exception);
}
So whenever a Pomodoro is completed, We need to call storeDatetoFile Method, Currently it's a simple text file that stores the start time of a Pomodoro and it's status (which is completed always)
storeDataToFile() {
fs.appendFile(this.fileName, this.currentTime + ",completed", (err) => console.log(err));
}
Tomorrow I will be working on improvising the Storage feature.
You can check the full code in my repo simple-pomodoro-timer
Posted on April 12, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
April 12, 2020