Skip to content

Commit

Permalink
Add watch API
Browse files Browse the repository at this point in the history
relevant ticket: yorkie-team/yorkie#5.
  • Loading branch information
hackerwins committed Jan 5, 2020
1 parent 2329975 commit caa8901
Show file tree
Hide file tree
Showing 12 changed files with 1,836 additions and 227 deletions.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cd ./yorkie-js-sdk
npm install

# build
npm run build
npm run build:dev
```

## Test yorkie-js-sdk with yorkie agent
Expand All @@ -43,11 +43,27 @@ npm run build
```

For generating proto messages and the service client stub classes with protoc and the protoc-gen-grpc-web.
```
# make sure both executable(protoc, protoc-gen-grpc-web) are discoverable from your PATH.
sudo mv ~/Downloads/protoc-gen-grpc-web-1.0.7-darwin-x86_64 /usr/local/bin/protoc-gen-grpc-web
chmod +x /usr/local/bin/protoc-gen-grpc-web

How to install protoc-gen-grpc-web: https://github.com/grpc/grpc-web#code-generator-plugin

```bash
# generate proto messages and the service client stub classes
npm run proto
npm run build:proto
```

## Test examples

```bash
# start mongoDB
./yorkie/docker-compose up

# start yorkie agent
./yorkie/bin/yorkie agent

# start envoy proxy
./yorkie-js-sdk/docker-compose up --build

# test
cd ./yorkie-js-sdk
npm run start:dev
```
7 changes: 6 additions & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@

// 02. create a document then attach it into the client.
const doc = yorkie.createDocument('examples', 'codemirror-1');
await client.attachDocument(doc);
await client.attach(doc);
await client.watch(doc);
client.subscribe(() => {
client.sync();
});

doc.update((root) => {
root.getOrCreateText('content');
});
Expand Down
Loading

0 comments on commit caa8901

Please sign in to comment.