Skip to content

Commit

Permalink
Don't immediately write
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Aug 2, 2023
1 parent 31da8d0 commit c34f623
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
14 changes: 7 additions & 7 deletions scripts/e2e-test-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const { readFileSync } = require('fs');

const versions = JSON.parse(readFileSync('./test/e2e/versions.json', 'utf8'));

// if (process.env.GITHUB_REF && process.env.GITHUB_REF.includes('release/')) {
// For release builds we test all versions
console.log(JSON.stringify(versions));
// } else {
// Otherwise we test the oldest version and the last 10 versions
// console.log(JSON.stringify([versions[0], ...versions.slice(-10)]));
// }}
if (process.env.GITHUB_REF && process.env.GITHUB_REF.includes('release/')) {
// For release builds we test all versions
console.log(JSON.stringify(versions));
} else {
// Otherwise we test the oldest version and the last 10 versions
console.log(JSON.stringify([versions[0], ...versions.slice(-10)]));
}
15 changes: 1 addition & 14 deletions src/main/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,28 +127,15 @@ export class BufferedWriteStore<T> extends Store<T> {
* @param id A unique filename to store this data.
* @param initial An initial value to initialize data with.
* @param throttleTime The minimum time between writes
* @param immediateFirstWrite Whether to write the first set immediately
*/
public constructor(
path: string,
id: string,
initial: T,
private readonly _throttleTime: number = 500,
private _immediateFirstWrite = true,
) {
public constructor(path: string, id: string, initial: T, private readonly _throttleTime: number = 500) {
super(path, id, initial);
}

/** @inheritdoc */
public override async set(data: T): Promise<void> {
this._data = data;

// If this is the first write, we write immediately
if (this._immediateFirstWrite) {
this._immediateFirstWrite = false;
return super.set(data);
}

this._pendingWrite = {
// We overwrite the data for the pending write so that the latest data is written in the next flush
data,
Expand Down

0 comments on commit c34f623

Please sign in to comment.