import { StoreAddress, Status } from './'; import { DisposableBase } from '../system/disposables'; import { Subscribable } from '../model/subscribable'; import { StoreBuilder } from '../model/storeBuilder'; export declare class EventBus extends DisposableBase { private _stores; private _dispatchSubject; private _haltingException; private _state; private _onErrorHandlers; private _diagnosticMonitor; constructor(); get currentStatus(): Status; storeBuilder(storeId: string, initialModel: TModel): StoreBuilder; private addStore; removeStore(storeId: string): void; isStoreRegistered(storeId: string): boolean; isStoreDispatchStatus(storeId: string, status: Status): boolean; /** * Exists for read only access to a model. * * Note: given this is JavaScript, it's up to the caller to not write against the model. * If you want to modify the model, publish an event to it. * * @param storeId */ getStoreModel(storeId: string): TModel; /** * Exists to find a model for read only access. * * Note: given this is JavaScript, it's up to the caller to not write against the model. * If you want to modify the model, publish an event to it. * * Returns the found model else null. * * @param predicate = a predicate which is used as a test against each model. Will stop on first match */ findStoreModel(predicate: (model: any) => boolean): any; publishEvent(storeId: string, eventType: string, event: any): void; publishEvent(storeAddress: StoreAddress, eventType: string, event: any): void; broadcastEvent(eventType: string, event: any): void; executeEvent(eventType: string, event: any): void; getStoreModelObservable(storeId: string): Subscribable; /** * Disposes the bus and every registered store. * Store subscriptions created via StoreBuilder.withEventSubscription() are disposed. */ dispose(): void; addOnErrorHandler(handler: (error: Error) => void): void; removeOnErrorHandler(handler: any): void; isOnDispatchLoopFor(storeId: string): boolean; private _getOrCreateStoreRecord; private _tryEnqueueEvent; /** * Queues the event on the store without processing it. Returns true if the store observes the event type and it was queued. * The store must be registered (hasModel). */ private _enqueueEvent; private _purgeEventQueues; private _dispatchEventToEventProcessors; private _dispatchEvent; private _dispatchModelUpdates; /** * Tries to find a StoreRecord with pending events. * StoreRecords with older enqueued events are returned first. * @private */ private _getNextStoreRecordWithQueuedEvents; private _throwIfHaltedOrDisposed; private _halt; }