Skip to content

Can't change attached document maintaining client #1353

@green-kong

Description

@green-kong

What happened:

First of all, I really appreciate about this beautiful opensource.

I'm making something using yorkie.
That is what i want.
Maintaining client, change attached document.
For this, I need to generate client and document first.
And attach document of course.
If i wanna change document, I detach a document which I attached right before.
Lastly, I generate new document, and try to attach document.
But have a problem to do this.

What you expected to happen:
Maintaining client, change attached document.

How to reproduce it (as minimally and precisely as possible):
You can check a problem with this code.

import yorkie from 'yorkie-js-sdk';

async function main() {
  const client = new yorkie.Client('https://api.yorkie.dev', {
    apiKey,
  });
  await client.activate();

  const doc = new yorkie.Document('my-first-document');
  const doc2 = new yorkie.Document('my-first-document2');

  // first doc attach
  await client.attach(doc);
  console.log('attach doc1');
  await client.detach(doc);
  console.log('detach doc1');

  // second doc attach
  await client.attach(doc2);
  console.log('attach doc2');
  await client.detach(doc2);
  console.log('detach doc2');

  // again first doc attach
  await client.attach(doc);
  console.log('attach doc1');
}
main();

Anything else we need to know?:

Environment:

  • Operating system:
  • Browser and version:
  • Yorkie version (use yorkie version):
  • Yorkie JS SDK version:

Metadata

Metadata

Assignees

No one assigned

    Labels

    critical 🚨Event that must be dealt with to ensure the system

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions