Skip to content

Conversation

@SnaveSutit
Copy link
Contributor

@SnaveSutit SnaveSutit commented Jan 7, 2026

  • Events are now defined using the BlockbenchEventMap interface.
  • Event data is now fully type-safe.

Event functions previously only allowed built-in events, but now users can define their own events with full type safety:

declare global {
    interface BlockbenchEventMap {
        my_event: {foo: boolean, bar: Cube}
    }
}
Blockbench.dispatchEvent('my_event', {foo: false, bar: new Cube()})

NOTE: Most built-in events have any as their datatype, as I'm not 100% sure what each event expects / allows.

@netlify
Copy link

netlify bot commented Jan 7, 2026

Deploy Preview for blockbench-dev failed.

Name Link
🔨 Latest commit 00cdc82
🔍 Latest deploy log https://app.netlify.com/projects/blockbench-dev/deploys/696971010b0c6f000826132c

@SnaveSutit SnaveSutit force-pushed the feature/improved-eventsystem-typing branch from e7d3d2a to 1641e8f Compare January 14, 2026 21:32
@SnaveSutit
Copy link
Contributor Author

Fixed merge conflict with plugin install / uninstall events PR

Provides auto-complete for built-in events, while also allowing users to define their own without red squigglies everywhere.
Adds type checking to event data in callbacks and `dispatchEvent` calls.

Only plugin load events have typed data at the moment. But all events are included in the Event map, so typing can be added over time.
- Renamed `EventName` -> `BlockbenchEventName`
- Renamed `EventMap` -> `BlockbenchEventMap`
(Renamed for clarity)

Since events can now be added by users using `interface` merging, I've removed the generic `string` type from event names.
@SnaveSutit SnaveSutit force-pushed the feature/improved-eventsystem-typing branch from f7a3577 to 00cdc82 Compare January 15, 2026 22:58
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

Successfully merging this pull request may close these issues.

1 participant