function createEventSharer(otherWorkspace) {
  return (e) => {
    if (
      !(e instanceof ProcedureBase) &&
      !(e instanceof Blockly.Events.VarBase)
    ) {
      return;
    }
    let event;
    try {
      event = Blockly.Events.fromJson(e.toJson(), otherWorkspace);
    } catch (e) {
      // Could not deserialize event. This is expected to happen. E.g.
      // when round-tripping parameter deletes, the delete in the
      // secondary workspace cannot be deserialized into the original
      // workspace.
      return;
    }
    event.run(true);
  };
}
Returns an event listener that shares procedure and var events from the
connected workspace to the other workspace.
@param {!Blockly.Workspace} otherWorkspace The workspace to share events to.
@returns {function(Blockly.Events.Abstract)} The listener.