docs: Update the tutorial on the README to use workspaces (#100)
This commit is contained in:
parent
ace841de73
commit
41fe0a27bc
2 changed files with 35 additions and 11 deletions
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
|
|
@ -6,10 +6,14 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- stable-*
|
- stable-*
|
||||||
|
paths-ignore:
|
||||||
|
- '**/*.md'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- stable-*
|
- stable-*
|
||||||
|
paths-ignore:
|
||||||
|
- '**/*.md'
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
|
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
|
||||||
|
|
|
||||||
42
README.md
42
README.md
|
|
@ -97,24 +97,40 @@ develop the app with normal repository calls against the wrapped `session`.
|
||||||
### 1. Add the package to the project
|
### 1. Add the package to the project
|
||||||
|
|
||||||
Since this package is still in development and not yet released to pub.dev,
|
Since this package is still in development and not yet released to pub.dev,
|
||||||
you need to add it as a git reference to the project. On the client, add the following to the `pubspec.yaml` file:
|
you need to add it as a git reference to the project. First, add it normally
|
||||||
|
on the server and client `pubspec.yaml` files.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
# your_project_client/pubspec.yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
serverpod_offline_sync_client:
|
serverpod_offline_sync_client: 4.0.0-beta.0
|
||||||
git: https://github.com/marcelomendoncasoares/serverpod_offline_sync.git
|
|
||||||
path: packages/serverpod_offline_sync_client
|
|
||||||
ref: main
|
|
||||||
```
|
```
|
||||||
|
|
||||||
And, on the server's `pubspec.yaml`, add the following:
|
```yaml
|
||||||
|
# your_project_server/pubspec.yaml
|
||||||
|
dependencies:
|
||||||
|
serverpod_offline_sync_server: 4.0.0-beta.0
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, on the workspace root `pubspec.yaml` file, add the following overrides:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
dependencies:
|
dependency_overrides:
|
||||||
|
serverpod_offline_sync_client:
|
||||||
|
git:
|
||||||
|
url: https://github.com/marcelomendoncasoares/serverpod_offline_sync.git
|
||||||
|
path: packages/serverpod_offline_sync_client
|
||||||
|
ref: main
|
||||||
serverpod_offline_sync_server:
|
serverpod_offline_sync_server:
|
||||||
git: https://github.com/marcelomendoncasoares/serverpod_offline_sync.git
|
git:
|
||||||
path: packages/serverpod_offline_sync_server
|
url: https://github.com/marcelomendoncasoares/serverpod_offline_sync.git
|
||||||
ref: main
|
path: packages/serverpod_offline_sync_server
|
||||||
|
ref: main
|
||||||
|
serverpod_offline_sync_shared:
|
||||||
|
git:
|
||||||
|
url: https://github.com/marcelomendoncasoares/serverpod_offline_sync.git
|
||||||
|
path: packages/serverpod_offline_sync_shared
|
||||||
|
ref: main
|
||||||
```
|
```
|
||||||
|
|
||||||
Be mindful that installing the package as a git reference to `main` is subject
|
Be mindful that installing the package as a git reference to `main` is subject
|
||||||
|
|
@ -186,7 +202,7 @@ version that includes the sync engine.
|
||||||
```dart
|
```dart
|
||||||
final session = CrdtDatabaseSession.wraps(
|
final session = CrdtDatabaseSession.wraps(
|
||||||
await client.createSession(databasePath, isDebugMode: kDebugMode),
|
await client.createSession(databasePath, isDebugMode: kDebugMode),
|
||||||
syncTables: [Person.t, Book.t, Author.t],
|
syncTables: [Person.t, Book.t, Author.t], // Must be the same as on the server.
|
||||||
persistentUserId: persistentUserId,
|
persistentUserId: persistentUserId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -196,6 +212,10 @@ await session.db.initialize();
|
||||||
|
|
||||||
Then, store the `session` instance in the service locator.
|
Then, store the `session` instance in the service locator.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The list of synced tables must be the same on the server and the client.
|
||||||
|
> Otherwise, all sync attempts will fail with a schema mismatch error.
|
||||||
|
|
||||||
### 5. Wire the sync call on the client
|
### 5. Wire the sync call on the client
|
||||||
|
|
||||||
Be sure to authenticate the client before calling the sync methods. Otherwise,
|
Be sure to authenticate the client before calling the sync methods. Otherwise,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue