Interface: IFilteredBus<Namespace, Subjects, FilterPayload>
Makaio Framework / bus-core / IFilteredBus
Interface: IFilteredBus<Namespace, Subjects, FilterPayload>
Section titled “Interface: IFilteredBus<Namespace, Subjects, FilterPayload>”Defined in: ../../../packages/bus-core/src/filtered-bus.ts:28
Filtered bus that applies a base filter to all subscriptions.
Created via ScopedBus.withFilter() or FilteredBus.withFilter().
Extends
Section titled “Extends”IScopedBusBase<Namespace>
Type Parameters
Section titled “Type Parameters”Namespace
Section titled “Namespace”Namespace extends string = string
The namespace domain string
Subjects
Section titled “Subjects”Subjects = unknown
SubjectRecord for payload types (unused, for type consistency)
FilterPayload
Section titled “FilterPayload”FilterPayload = unknown
Pre-computed filter payload type for type-safe withFilter
Properties
Section titled “Properties”namespace
Section titled “namespace”
readonlynamespace:Namespace
Defined in: ../../../packages/bus-core/src/scoped-bus-base.ts:27
Inherited from
Section titled “Inherited from”IScopedBusBase.namespace
Methods
Section titled “Methods”emit()
Section titled “emit()”emit<
Subject>(subject,payload):Promise<void>
Defined in: ../../../packages/bus-core/src/scoped-bus-base.ts:83
Emit an event.
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends ScopedSubjectDefinition<Namespace>
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition to emit on
payload
Section titled “payload”Subject["$meta"]["payload"]
Event payload matching the subject schema
Returns
Section titled “Returns”Promise<void>
Promise resolving when all handlers have been notified
Inherited from
Section titled “Inherited from”IScopedBusBase.emit
getFilter()
Section titled “getFilter()”getFilter():
PayloadFilter|undefined
Defined in: ../../../packages/bus-core/src/filtered-bus.ts:36
Get the current base filter.
Returns
Section titled “Returns”PayloadFilter | undefined
intercept()
Section titled “intercept()”intercept<
Subject>(subject,handler,options?): () =>void
Defined in: ../../../packages/bus-core/src/scoped-bus-base.ts:49
Register an interceptor that runs BEFORE handlers.
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends ScopedSubjectDefinition<Namespace>
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition to intercept
handler
Section titled “handler”InterceptorHandler<Subject["$meta"]["payload"]>
Interceptor handler function
options?
Section titled “options?”InterceptOptions
Optional intercept options (filter, priority, etc.)
Returns
Section titled “Returns”Unsubscribe function
() => void
Inherited from
Section titled “Inherited from”IScopedBusBase.intercept
on<
Subject>(subject,handler,options?): () =>void
Defined in: ../../../packages/bus-core/src/scoped-bus-base.ts:36
Register an event or request handler.
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends ScopedSubjectDefinition<Namespace>
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition to listen on
handler
Section titled “handler”HandlerForSubjectDefinition<Subject>
Handler function to invoke
options?
Section titled “options?”Optional subscription options (filter, priority, etc.)
Returns
Section titled “Returns”Unsubscribe function
() => void
Inherited from
Section titled “Inherited from”IScopedBusBase.on
once()
Section titled “once()”Call Signature
Section titled “Call Signature”once<
Subject>(subject,handler): () =>void
Defined in: ../../../packages/bus-core/src/scoped-bus-base.ts:61
Register a one-time handler (callback version).
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends ScopedSubjectDefinition<Namespace>
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition to listen on once
handler
Section titled “handler”HandlerForSubjectDefinition<Subject>
Handler function invoked at most once
Returns
Section titled “Returns”Unsubscribe function
() => void
Inherited from
Section titled “Inherited from”IScopedBusBase.once
Call Signature
Section titled “Call Signature”once<
Subject>(subject,options?):Promise<ContextForSubjectDefinition<Subject>>
Defined in: ../../../packages/bus-core/src/scoped-bus-base.ts:72
Wait for an event (promise version).
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends ScopedSubjectDefinition<Namespace>
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition to await
options?
Section titled “options?”OnceOptions<Subject>
Optional filter and timeout options
Returns
Section titled “Returns”Promise<ContextForSubjectDefinition<Subject>>
Promise resolving to the event context
Inherited from
Section titled “Inherited from”IScopedBusBase.once
request()
Section titled “request()”request<
Subject>(subject,payload):Promise<Subject["$meta"]["payload"]["response"]>
Defined in: ../../../packages/bus-core/src/scoped-bus-base.ts:94
Make a request (throws if no handler is registered).
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends ScopedSubjectDefinition<Namespace>
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition for the request
payload
Section titled “payload”Subject["$meta"]["payload"]["request"]
Request payload matching the subject schema
Returns
Section titled “Returns”Promise<Subject["$meta"]["payload"]["response"]>
Promise resolving to the response payload
Inherited from
Section titled “Inherited from”IScopedBusBase.request
requestOptional()
Section titled “requestOptional()”requestOptional<
Subject>(subject,payload):Promise<OptionalResult<Subject["$meta"]["payload"]["response"]>>
Defined in: ../../../packages/bus-core/src/scoped-bus-base.ts:106
Make an optional request (returns OptionalResult instead of throwing
when no handler is registered).
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends ScopedSubjectDefinition<Namespace>
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition for the request
payload
Section titled “payload”Subject["$meta"]["payload"]["request"]
Request payload matching the subject schema
Returns
Section titled “Returns”Promise<OptionalResult<Subject["$meta"]["payload"]["response"]>>
Promise resolving to an OptionalResult wrapper
Inherited from
Section titled “Inherited from”IScopedBusBase.requestOptional
withFilter()
Section titled “withFilter()”withFilter(
filter):IFilteredBus<Namespace,Subjects,FilterPayload>
Defined in: ../../../packages/bus-core/src/filtered-bus.ts:56
Create a new FilteredBus with additional filter conditions merged in. Later filters override earlier ones for the same path.
When FilterPayload is known, filter keys are automatically type-checked.
Parameters
Section titled “Parameters”filter
Section titled “filter”TypedPayloadFilter<FilterPayload>
Additional filter conditions to merge
Returns
Section titled “Returns”IFilteredBus<Namespace, Subjects, FilterPayload>
New FilteredBus with merged filter
Example
Section titled “Example”// Type-safe filtering - keys validated against FilterPayloadconst agentBus = bus.withFilter({ agentId: 'agent-123' }); // ✅const badBus = bus.withFilter({ unknownKey: 'x' }); // ❌ Error
// Explicit type overrideinterface CustomPayload { agentId: string; status: string }const strictBus = bus.withFilter<CustomPayload>({ agentId: 'agent-123' });