import { Vain } from '../vain'; import { Particle } from '../particles'; import type { Data } from './data.atom'; import type { Mutation } from './mutation.atom'; import type { DataMediator, MutationMediator } from '../mediators'; import type { AnyFunction, AnyStringRecord, CastAny, First, Last } from '../../@types'; /****************************************************************************************************** * * Atoms * ******************************************************************************************************/ /** * Number of atoms is finite. Using a enum to group them is reasonable. */ export declare enum AtomType { Data = "[atom Data]", Mutation = "[atom Mutation]" } /****************************************************************************************************** * * Atom Predicates * ******************************************************************************************************/ /** * */ export interface AtomLike { isAtom: boolean; atomType: AtomType; particleName: string; metaName: string; particle: Particle; meta: any; options: AnyStringRecord; subscribe: (consumer: (particle: Particle, atom?: AtomLike) => void, options?: AnyStringRecord) => Subscription; getSubscriptionByConsumer: (consumer: (particle: Particle, atom?: AtomLike) => void) => Subscription | undefined; getSubscriptionByHostAtom: (hostAtom: AtomLike) => Subscription | undefined; getSubscription: (consumerOrHostAtom: ((particle: Particle, atom?: AtomLike) => void) | AtomLike) => Subscription | undefined; unsubscribe: (target: ((particle: Particle, atom?: AtomLike) => void) | Subscription | AtomLike) => boolean; unsubscribeAll: () => boolean; trigger: (particle?: any) => void; observe: (atom?: any) => Subscription; unobserve: (atom?: any) => boolean; unobserveAll: () => boolean; beObservedBy: (atom?: any) => Subscription; pipe: (...fns: FNS) => FNS extends [] ? [] : ReturnType>>; compose: (...fns: AnyFunction[]) => FNS extends [] ? [] : ReturnType>>; } export declare type DataLike = Data | DataMediator; export declare type MutationLike

= Mutation | MutationMediator; /** * AtomLike that can take any as input and any as output. */ export declare type AtomLikeOfAny = Data | DataMediator | Mutation | MutationMediator; /** * AtomLike that can take I as input. */ export declare type AtomLikeOfInput = Data | DataMediator | Mutation | MutationMediator; /** * AtomLike that can emit O as output. */ export declare type AtomLikeOfOutput = Data | DataMediator | Mutation | MutationMediator; /** * Target will be considered `AtomLike` when its `isAtom` property is true, etc. Data, Mutation, DataMediator, MutationMediator. */ export declare const isAtomLike: (target: any) => target is AtomLike; /** * Target will be considered `DataLike` when its `isData` property is true, etc. `Data` or `DataMediator`. */ export declare function isDataLike(target: DataLike): target is DataLike; export declare function isDataLike(target: unknown): target is DataLike; /** * Target will be considered `MutationLike` when its `isMutation` property is true, etc. `Mutation` or `MutationMediator`. */ export declare function isMutationLike

(target: MutationLike): target is MutationLike; export declare function isMutationLike

(target: unknown): target is MutationLike; /** * @param target anything * @return { boolean } whether the target is an Atom instance */ export declare const isAtom: (target: any) => target is BaseAtom; /****************************************************************************************************** * * Atom Classes * ******************************************************************************************************/ /** * */ declare type Unary = (input: I) => O; /** * */ export interface BaseAtomOptions { isAsync?: boolean; } export declare const DEFAULT_BASEATOM_OPTIONS: Required; /** * @important please consider BaseMediator when add property or method to Atom * !! */ export declare abstract class BaseAtom extends Vain { constructor(); abstract get atomType(): AtomType; abstract get particleName(): string; abstract get metaName(): string; abstract get particle(): Particle; abstract get meta(): any; get isAtom(): boolean; abstract get options(): AnyStringRecord; abstract setOptions(key: keyof BaseAtomOptions, value: BaseAtomOptions[Key]): void; pipe(): this; pipe(fn1: Unary): A; pipe(fn1: Unary, fn2: Unary): B; pipe(fn1: Unary, fn2: Unary, fn3: Unary): C; pipe(fn1: Unary, fn2: Unary, fn3: Unary, fn4: Unary): D; pipe(fn1: Unary, fn2: Unary, fn3: Unary, fn4: Unary, fn5: Unary): E; pipe(fn1: Unary, fn2: Unary, fn3: Unary, fn4: Unary, fn5: Unary, fn6: Unary): F; pipe(fn1: Unary, fn2: Unary, fn3: Unary, fn4: Unary, fn5: Unary, fn6: Unary, fn7: Unary): G; pipe(fn1: Unary, fn2: Unary, fn3: Unary, fn4: Unary, fn5: Unary, fn6: Unary, fn7: Unary, fn8: Unary): H; pipe(fn1: Unary, fn2: Unary, fn3: Unary, fn4: Unary, fn5: Unary, fn6: Unary, fn7: Unary, fn8: Unary, fn9: Unary): I; pipe(fn1: Unary, fn2: Unary, fn3: Unary, fn4: Unary, fn5: Unary, fn6: Unary, fn7: Unary, fn8: Unary, fn9: Unary, fn10: Unary): J; pipe(fn1: Unary, fn2: Unary, fn3: Unary, fn4: Unary, fn5: Unary, fn6: Unary, fn7: Unary, fn8: Unary, fn9: Unary, fn10: Unary, ...fns: Array>): any; compose(): this; compose(fn1: Unary): A; compose(fn2: Unary, fn1: Unary): B; compose(fn3: Unary, fn2: Unary, fn1: Unary): C; compose(fn4: Unary, fn3: Unary, fn2: Unary, fn1: Unary): D; compose(fn5: Unary, fn4: Unary, fn3: Unary, fn2: Unary, fn1: Unary): E; compose(fn6: Unary, fn5: Unary, fn4: Unary, fn3: Unary, fn2: Unary, fn1: Unary): F; compose(fn7: Unary, fn6: Unary, fn5: Unary, fn4: Unary, fn3: Unary, fn2: Unary, fn1: Unary): G; compose(fn8: Unary, fn7: Unary, fn6: Unary, fn5: Unary, fn4: Unary, fn3: Unary, fn2: Unary, fn1: Unary): H; compose(fn9: Unary, fn8: Unary, fn7: Unary, fn6: Unary, fn5: Unary, fn4: Unary, fn3: Unary, fn2: Unary, fn1: Unary): I; compose(fn10: Unary, fn9: Unary, fn8: Unary, fn7: Unary, fn6: Unary, fn5: Unary, fn4: Unary, fn3: Unary, fn2: Unary, fn1: Unary): J; } /****************************************************************************************************** * * Atom Related Types * ******************************************************************************************************/ /** *—————————————————————————————————————————————— Subscribe Related ———————————————————————————————————————————————————— */ /** * */ export interface SubscribeOptions { hostAtom?: AtomLike | null; isExtracted?: boolean; } export declare const DEFAULT_SUBSCRIBE_OPTIONS: Required; export interface Subscription { hostAtom?: AtomLike; subscribeOptions: SubscribeOptions; originalConsumer: AnyFunction; proxyConsumer: (particle: any, atom?: any) => void; unsubscribe: () => boolean; } /** *—————————————————————————————————————————————— Trigger Related ———————————————————————————————————————————————————— */ /** * */ export interface AtomTriggerRegisterOptions { forceWrap?: boolean; } export declare const DEFAULT_ATOM_TRIGGER_REGISTER_OPTIONS: Required; export interface TriggerController { start?: () => void; pause?: () => void; cancel?: () => void; } export declare type InternalTrigger = (accepted: Accepted, ...args: any[]) => void; export declare type Trigger = (internalTrigger: InternalTrigger) => TriggerController; export {}; //# sourceMappingURL=base.atom.d.ts.map