import type { PrimitiveObject } from '../libs/bemedev/globals/types'; import type { ActorsConfigMap, EventObject, EventsMap, ToEventObject, ToEvents } from '../events/index.js'; import type { State } from '../states/index.js'; import type { TimerState } from '@bemedev/interval2'; import { FnMapR } from '../types/primitives'; /** * Subscriber class that manages the subscription state and provides methods * to handle state changes and unsubscribe. * * @template : {@linkcode EventsMap} [E] - Type of the events map * @template : {@linkcode ActorsConfigMap} [A] - Type of the actors map * @template : {@linkcode PrimitiveObject} [Tc] - Type of the context * @template : [R] - Type of the return value * */ declare class SubscriberClass> = ToEventObject>, St extends State = State> { #private; private _id; get id(): string; get equals(): (previous: St, next: St) => boolean; /** * Creates an instance of SubscriberMapClass. * @param eventsMap - {@linkcode EventsMap} [E] - The events map. * @param promiseesMap - {@linkcode PromiseeMap} [P] - The promisees map. * @param subscriber - The {@linkcode FnSubReduced} subscriber function or object. * @param equals - Function to compare two {@linkcode State}s for equality (optional). * @param _id - Unique identifier for the subscriber (optional). */ constructor(eventsMap: E, actorsMap: A, subscriber: FnMapR, equals?: (a: St, b: St) => boolean, _id?: string); /** * Function to handle state changes. * @param previous of type {@linkcode State} - Previous state * @param next of type {@linkcode State} - Next state * * @remarks * This function checks if the subscriber can perform its action, * compares the previous and next states using the provided equality function, * and if they are not equal, it calls the subscriber with the next state. * If the states are equal or if the subscriber cannot perform its action, */ fn: (previous: St, next: St) => any; get state(): TimerState; close: () => void; open: () => void; unsubscribe: () => void; } export type { SubscriberClass }; export type SubscriberOptions = { id?: string; equals?: (a: State, b: State) => boolean; }; type CreateSubscriber_F = > = ToEventObject>>(eventsMap: E, actorsMap: A, subscriber: FnMapR, options?: SubscriberOptions) => SubscriberClass; /** * Creates a new instance of SubscriberMapClass. * * @param eventsMap : {@linkcode EventsMap} [E] - The events map. * @param actorsMap : {@linkcode ActorsConfigMap} [A] - The actors map. * @param subscriber - The subscriber function that will be called with the {@linkcode State}. * @param options - Optional parameters for the subscriber, including equality function and ID. * @returns A new instance of {@linkcode SubscriberClass} that manages the subscription state and provides methods to handle state changes and unsubscribe. * * @remarks * This function maps the provided events and actors. * * This allows for efficient subscription management and state handling depending on the events and actors. */ export declare const createSubscriber: CreateSubscriber_F; //# sourceMappingURL=subscriber.d.ts.map