Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 10 additions & 6 deletions demos/angular-supabase-todolist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ A step-by-step guide on Supabase<>PowerSync integration is available [here](http
## Quick Start

1. Run `pnpm install`
2. Create a `.env` file by copying the template `cp .env.template .env`
3. Populate the `.env` file with PowerSync and Supabase details
4. Run `pnpm watch` to build application and check for code changes
5. In a new terminal run `pnpm start` to start the server
6. Go to <http://localhost:8080>
2. Run `pnpm powersync-web copy-assets -o src/assets` to copy the worker assets into the project.
3. Create a `.env` file by copying the template `cp .env.template .env`
4. Populate the `.env` file with PowerSync and Supabase details
5. Run `pnpm watch` to build application and check for code changes
6. In a new terminal run `pnpm start` to start the server
7. 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 (`step 2`) and ensure the worker paths are specified ([example here](./src/app/powersync.service.ts)).

## Development Server

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