Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize multiple views of the same editor model #10

Open
matthewturk opened this issue Mar 7, 2022 · 3 comments
Open

Synchronize multiple views of the same editor model #10

matthewturk opened this issue Mar 7, 2022 · 3 comments

Comments

@matthewturk
Copy link
Member

We should have multiple views of an editor kept in sync. This simplistic method does not work:

async updateViews(newConfig: Data, skipId?: string): Promise<void> {
    if (this.isLocked) {
      console.log('Locked, so returning');
      return;
    }
    this.isLocked = true;
    for (const viewId of Object.keys(this.views)) {
      if (viewId === skipId) {
        continue;
      }
      await this.views[viewId].then(v => {
        (v as ReteEditorView).editor.fromJSON(newConfig);
      });
    }
    this.isLocked = false;
  }

and then linking this via watching:

    this.editor.on(
      ['nodecreated', 'noderemoved', 'connectioncreated', 'connectionremoved'],
      async () => {
        this.model.updateViews(this.editor.toJSON(), this.id);
      }
    );

causes a nice infinite loop, even with just one editor. I think this is because the multiple views all get these new events one after another because the new nodes keep getting added as a result of the nodes becoming unbound from their python proxy instances. But I am not entirely certain yet, and I'm going to continue investigating.

@matthewturk
Copy link
Member Author

As soon as I filed the bug I think I found a fix, which is to ensure that the updateViews method is always called after the createNewNode method.

@matthewturk
Copy link
Member Author

Red herring. I believe that we may need to add synchronization of state between editor models for specific changes to individual nodes, or somehow mirroring the node elements that map directly to canvas elements.

@matthewturk
Copy link
Member Author

addressed in #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant