Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions demos/angular-supabase-todolist/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,5 @@ testem.log
# System files
.DS_Store
Thumbs.db

src/assets/@powersync
5 changes: 4 additions & 1 deletion demos/angular-supabase-todolist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ A step-by-step guide on Supabase<>PowerSync integration is available [here](http
5. In a new terminal run `pnpm start` to start the server
6. Go to <http://localhost:8080>

**Note:** The Angular development server (`pnpm serve`) doesn't support service worker applications
### Notes

- The Angular development server (`pnpm serve`) doesn't support service worker applications
- For Angular, workers need to be configured when instantiating `PowerSyncDatabase`. To do this, copy the worker assets (`pnpm powersync-web copy-assets -o src/assets` - done automatically as a `postinstall` step in this demo) and ensure the worker paths are specified ([example here](./src/app/powersync.service.ts)).

## Development Server

Expand Down
3 changes: 2 additions & 1 deletion demos/angular-supabase-todolist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build": "ng build",
"format": "prettier --write .",
"test:build": "pnpm build",
"watch": "ng build --watch --configuration development"
"watch": "ng build --watch --configuration development",
"postinstall": "[ \"$GITHUB_ACTIONS\" = \"true\" ] || pnpm powersync-web copy-assets -o src/assets"
},
"private": true,
"dependencies": {
Expand Down
19 changes: 15 additions & 4 deletions demos/angular-supabase-todolist/src/app/powersync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
Index,
IndexedColumn,
PowerSyncBackendConnector,
PowerSyncDatabase,
Schema,
Table,
WASQLitePowerSyncDatabaseOpenFactory
WASQLiteOpenFactory
} from '@powersync/web';

export interface ListRecord {
Expand Down Expand Up @@ -63,11 +64,21 @@ export class PowerSyncService {
db: AbstractPowerSyncDatabase;

constructor() {
const PowerSyncFactory = new WASQLitePowerSyncDatabaseOpenFactory({
const factory = new WASQLiteOpenFactory({
dbFilename: 'test.db',

// Specify the path to the worker script
worker: 'assets/@powersync/worker/WASQLiteDB.umd.js'
});

this.db = new PowerSyncDatabase({
schema: AppSchema,
dbFilename: 'test.db'
database: factory,
sync: {
// Specify the path to the worker script
worker: 'assets/@powersync/worker/SharedSyncImplementation.umd.js'
}
});
this.db = PowerSyncFactory.getInstance();
}

setupPowerSync = async (connector: PowerSyncBackendConnector) => {
Expand Down
Loading