π Random Laravel experiment: type-safe broadcasting.
I implemented `HasBroadcastChannel` on an enum so I could use it in place of channel names. By using `spatie/laravel-typescript-transformer`, I can convert the enum to a TypeScript definition and make a type-safe front-end helper!
I implemented `HasBroadcastChannel` on an enum so I could use it in place of channel names. By using `spatie/laravel-typescript-transformer`, I can convert the enum to a TypeScript definition and make a type-safe front-end helper!
1 / 4
Comments
Not sure about model events, I don't use theseβyou'd probably want custom events
```ts
type Channel = ChannelName | PrivateChannelName
type ChannelWithId = `${Channel}:${string}`
// function subscribeTo(channel: Channel | ChannelWithId) {}
```