Skip to content

Create a demo page for shared procedures #6512

@BeksOmega

Description

@BeksOmega

Problem Statement

We need a page that we can use to test shared procedures manually (for behaviors that are difficult to unit test). We also need something external developers can play with to show off the new functionality.

Proposed Solution

Create a test page that has two workspaces. The workspaces should have the following toolbox categories:

  • Procedures (obvs)
  • Variables (so that we can test sharing these as well)
  • Some various blocks with different connections (output, input, next, prev, statement) so that we can make stacks.

Then add some code to actually share the procedures between workspaces:

const workspace1 = Blockly.inject('blocklyDiv1', {});
const workspace2 = Blockly.inject('blocklyDiv2', {});

function createChangeListener(otherWs) {
  return (e) => {
    if (e.type === Blockly.PROCEDURE_CREATE ||
      e.type === Blockly.PROCEDURE_DELETE ||
      etc...) {
      Blockly.Events.fromJson(e.toJson(), otherWs).run(true);
    }
  }
}

workspace1.addChangeListener(createChangeListener(workspace2));
workspace2.addChangeListener(createChangeListener(workspace1));

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions