Skip to content

Events cannot be fired from block initialization #6840

@BeksOmega

Description

@BeksOmega

Check for duplicates

  • I have searched for similar issues before opening a new one.

Problem

We can't fire events from block initialization because events are disabled when:

  1. Deserializing blocks
  2. Creating blocks from the flyout

This is an unfortunate situation when you want your blocks to create backing data models. For example, if you drag a variable block from the flyout, it will create a the backing variable model, but the variable event will not be fired automatically. The flyout code has to manually check for created variable models, and then fire events for those.

This is not extensible. E.g. the procedure blocks that use backing data models (@blockly/block-sharable-procedures) cannot use this method to fire create events for the procedure data models.

Request

Add some way to fire events during block initialization. One option would be to figure out why we're disabling events during deserialization (I'm assuming it's because we don't want to end up with a bunch of BlockChange events for fields and such) and try to find a different way to work around that issue.

Alternatives considered

Another option would be to add a way to be able to add a callback or event to the flyout so we can fire events after blocks are dragged from the flyout.

We would need to make sure that this API is robust enough to handle event ordering (e.g. ideally we would want backing-data-model events to be fired before block create events, to support real time collaboration).

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions