UNPKG

react-http-fetch

Version:

An http library for React JS built on top of native JS fetch

46 lines (45 loc) 1.5 kB
import { HttpEvent } from './events'; import { HttpEventHandler, HttpEventClassType } from './types'; export declare class EventBus { private _subscriptions; /** * @constructor */ constructor(); /** * Gets the set of subscriptions associated with the provided http event class type. */ private _ensureEventSubscriptionInit; /** * Gets the number of subscriptions for the given event. * @param {*} eventName */ getEventSubscriptionsCount<PayloadT>(httpEventType: HttpEventClassType<PayloadT>): number; /** * Subscribes to an event. * @param {*} eventName * @param {*} handler */ subscribe<PayloadT>(httpEventType: HttpEventClassType<PayloadT>, handler: HttpEventHandler<PayloadT>): () => void; /** * Publishes an event against to set of subscribers. * @param {*} eventName * @param {*} payload */ publish<PayloadT>(httpEvent: HttpEvent<PayloadT>): void; /** * Deregister the handler for the event name. * @param {*} eventName * @param {*} subscription */ unsubscribe<PayloadT>(httpEventType: HttpEventClassType<PayloadT>, handler: HttpEventHandler<PayloadT>): void; /** * Detaches all subscriptions for the given event. * @param {*} eventName */ detachEventSubscriptions<PayloadT>(httpEventType: HttpEventClassType<PayloadT>): void; /** * Detaches the subscriptions for all registered events. */ detachAll(): void; }