Skip to main content
Partas

Event Bus

createEventBus

let createEventBus<'T>(): EventBus<'T>

See EventBus

createEmitter

let createEmitter<'T>(): Emitter<'T>

See Emitter

createMappedEmitter

let createMappedEmitter<'MessageSchema>(): MappedEmitter<'MessageSchema>

See MappedEmitter which is a F# friendly binding.

createEventHub

let createEventHub<'T> (?channels: 'T): EventHub<'T>

See EventHub

EventBus

See createEventBus.

type EventBus<'T> = interface

Provides all base functions of an event-emitter, plus additional functions for managing listeners.

Its behavior could be customized with a config object. Good for advanced usage.

member listen: ('T -> unit) -> DisposeCallback

The disposal will be called automatically on cleanup. Use the callback to cleanup the resource earlier if required.

member emit: 'T -> unit
member clear: unit -> unit

Emitter

See createEmitter and see createMappedEmitter with the F# friendly version MappedEmitter

type Emitter<'MessageTyper> = interface

An emitter which you can listen to and emit various events.

member on: (string * (obj -> unit)) -> DisposeCallback

The sub is cleaned up automatically on dismount, but you can cleanup the resource earlier if required.

member emit: (string * obj) -> unit
member clear: unit -> unit

MappedEmitter

See createMappedEmitter

type MappedEmitter<'MessageMapper> = interface

This is a typesafe version of the Emitter made for F#/Fable.

It uses the path from the type to its member as the key of the emission. Because we provide a typed path, we get the benefit of having the member being typed as the message type.

member on
(mapping: 'MessageMapper -> 'MessageType)
(callback: 'MessageType -> unit)
: DisposeCallback
member emit
(mapping: 'MessageMapper -> 'MessageType)
(message: 'MessageType)
: unit
member clear: unit -> unit

GlobalEmitter

type GlobalEmitter<'T> = inherit Emitter<'T>

A wrapper around createEmitter. Creates an emitter with which you can listen to and emit various events. With this emitter you can also listen to all events.

member listen (obj -> unit): DisposeCallback

EventHub

See createEventHub

type EventHub<'T> = inherit GlobalEmitter<'T.

Provides helpers for using a group of event buses. Can be used with createEventBus, createEventStack or any emitter with the same api.

warning

Not much more has been bound for this type. I think I was intending to build a type provider for this. Which is a lot of effort for not much worth (to me right now).

Last updated: 7/11/25, 1:35 AM

PartasBuilt using the Partas.SolidStart SolidBase template
Community
githubdiscord