Skip to content

Commit

Permalink
Add simultaneous cursors example and Update examples to v0.4.6 (#581)
Browse files Browse the repository at this point in the history
Co-authored-by: YoonKiJin <[email protected]>
Co-authored-by: Youngteac Hong <[email protected]>
  • Loading branch information
3 people authored Aug 29, 2023
1 parent 5527603 commit f45593f
Show file tree
Hide file tree
Showing 46 changed files with 2,839 additions and 16,708 deletions.
9 changes: 3 additions & 6 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ services:
# If you're using Mac or Windows, this special domain name("host.docker.internal" which makes containers able to connect to the host)
# is supported by default.
# But if you're using Linux and want an envoy container to communicate with the host,
# it may help to define "host.docker.internal" in extra_hosts.
# it may help to define "host.docker.internal" in extra_hosts.
# (Actually, other hostnames are available, but in that case you should update clusters[].host configurations of envoy.yaml)
extra_hosts:
- "host.docker.internal:host-gateway"
- 'host.docker.internal:host-gateway'
yorkie:
image: 'yorkieteam/yorkie:latest'
container_name: 'yorkie'
command: [
'server',
'--enable-pprof',
]
command: ['server', '--enable-pprof']
restart: always
ports:
- '11101:11101'
Expand Down
24 changes: 11 additions & 13 deletions examples/profile-stack/main.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import yorkie from 'yorkie-js-sdk';
import yorkie, { DocEventType } from 'yorkie-js-sdk';
import { getRandomName, getRandomColor } from './util.js';

async function main() {
const client = new yorkie.Client(import.meta.env.VITE_YORKIE_API_ADDR, {
apiKey: import.meta.env.VITE_YORKIE_API_KEY,
});
await client.activate();
const doc = new yorkie.Document('profile-stack');
doc.subscribe('presence', (event) => {
if (event.type !== DocEventType.PresenceChanged) {
displayPeerList(doc.getPresences(), client.getID());
}
});
await client.attach(doc, {
// set the client's name and color to presence.
presence: {
initialPresence: {
name: getRandomName(),
color: getRandomColor(),
},
});
await client.activate();

client.subscribe((event) => {
if (event.type === 'peers-changed') {
// show peer list
displayPeerList(client.getPeersByDocKey(doc.getKey()), client.getID());
}
});

const doc = new yorkie.Document('profile-stack');
await client.attach(doc);

window.addEventListener('beforeunload', () => {
client.deactivate();
Expand Down
334 changes: 0 additions & 334 deletions examples/profile-stack/package-lock.json

This file was deleted.

Loading

0 comments on commit f45593f

Please sign in to comment.