Skip to content

Commit

Permalink
improve crud watching
Browse files Browse the repository at this point in the history
  • Loading branch information
stevensJourney committed Jan 15, 2024
1 parent 1f08fc5 commit ff6a918
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
this.sdkVersion = version.rows?.item(0)['powersync_rs_version()'] ?? '';
this.ready = true;
this.iterateListeners((cb) => cb.initialized?.());
this.watchCrudUploads();
}

/**
Expand All @@ -159,11 +158,10 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
protected async watchCrudUploads() {
for await (const event of this.onChange({
tables: [PSInternalTable.CRUD],
rawTableNames: true
rawTableNames: true,
signal: this.abortController?.signal
})) {
if (this.connected) {
this.syncStreamImplementation?.triggerCrudUpload();
}
this.syncStreamImplementation?.triggerCrudUpload();
}
}

Expand Down Expand Up @@ -195,6 +193,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
// Begin network stream
this.syncStreamImplementation.triggerCrudUpload();
this.syncStreamImplementation.streamingSync(this.abortController.signal);
this.watchCrudUploads();
}

async disconnect() {
Expand Down Expand Up @@ -381,8 +380,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
*/
async execute(sql: string, parameters?: any[]) {
await this.waitForReady();
const result = await this.database.execute(sql, parameters);
return result;
return this.database.execute(sql, parameters);
}

/**
Expand Down

0 comments on commit ff6a918

Please sign in to comment.