import type { SynthesizeEvent } from '../../@types'; import type { Trigger } from '../atoms'; import type { Observable } from 'rxjs'; /************************************************************************************************************************ * * IterableTrigger creators * ************************************************************************************************************************/ /** * */ interface IterableTriggerCreateOptions { iterable: Iterable; autoStart?: boolean; repeatable?: boolean; handler?: (arg: V, ...args: any[]) => R; } /** * @param options.iterable which values will be trigged in sequence * @param [options.autoStart = false] indicate if the iterable will be iterated automatically * @param [options.repeatable = true] indicate if the iterable will be iterated repeatedly * @param [options.handler = asIs] will be apply to values before them passed to trigger */ export declare const createIterableTrigger: (options: IterableTriggerCreateOptions) => Trigger; export declare const createDataFromIterable: (options: IterableTriggerCreateOptions) => [import("../atoms").Data, import("..").TriggerDataMediator, import("..").TriggerMediatorOptions, import("../atoms").DataTrigger, import("../atoms").TriggerController]; export declare const createMutationFromIterable: (options: IterableTriggerCreateOptions) => [import("../atoms").Mutation, import("..").TriggerMutationMediator, import("..").TriggerMediatorOptions, import("../atoms").MutationTrigger, import("../atoms").TriggerController]; /************************************************************************************************************************ * * EventTrigger creators * ************************************************************************************************************************/ /** * */ interface EventTriggerCreateOptions> { target: Target; type: string; autoStart?: boolean; handler?: (event: SynthesizeEvent, ...args: any[]) => Returned; } /** * @param options.target which has addEventListener method & removeEventListener method * @param options.type event type which will pass as first argument of addEventListener & removeEventListener * @param [options.autoStart = true] indicate if the event will be listened automatically * @param [options.handler = asIs] will be apply to event argument before it passed to trigger */ export declare const createEventTrigger: >(options: EventTriggerCreateOptions) => Trigger; export declare const createDataFromEvent: >(options: EventTriggerCreateOptions) => [import("../atoms").Data, import("..").TriggerDataMediator, import("..").TriggerMediatorOptions, import("../atoms").DataTrigger, import("../atoms").TriggerController]; export declare const createMutationFromEvent: >(options: EventTriggerCreateOptions) => [import("../atoms").Mutation, import("..").TriggerMutationMediator, import("..").TriggerMediatorOptions, import("../atoms").MutationTrigger, import("../atoms").TriggerController]; /************************************************************************************************************************ * * IntervalTrigger creators * ************************************************************************************************************************/ /** * */ interface IntervalTriggerCreateOptions { start?: number; step?: number; interval?: number; autoStart?: boolean; handler?: (arg: number, ...args: any[]) => R; } /** * @param [options.start = 0] (in millisecond) will be the start value of interval value * @param [options.step = 1000] (in millisecond) will add to start value when interval goes * @param [options.interval = 1000] (in millisecond) will be the ms argument of setInterval * @param [options.autoStart = true] indicate if the interval will auto start * @param [options.handler = asIs] will be apply to interval value before it passed to trigger * @return Trigger */ export declare const createIntervalTrigger: (options: IntervalTriggerCreateOptions) => Trigger; export declare const createDataFromInterval: (options: IntervalTriggerCreateOptions) => [import("../atoms").Data, import("..").TriggerDataMediator, import("..").TriggerMediatorOptions, import("../atoms").DataTrigger, import("../atoms").TriggerController]; export declare const createMutationFromInterval: (options: IntervalTriggerCreateOptions) => [import("../atoms").Mutation, import("..").TriggerMutationMediator, import("..").TriggerMediatorOptions, import("../atoms").MutationTrigger, import("../atoms").TriggerController]; /************************************************************************************************************************ * * TimeoutTrigger creators * ************************************************************************************************************************/ /** * */ interface TimeoutTriggerCreateOptions { timeout: number; autoStart?: boolean; handler?: (arg: number, ...args: any[]) => R; } /** * @param options.timeout (in millisecond) will be the ms argument of setTimeout * @param [options.autoStart = true] indicate if the timeout will auto start * @param [options.handler = asIs] result of its execution will be passed to trigger */ export declare const createTimeoutTrigger: (options: TimeoutTriggerCreateOptions) => Trigger; export declare const createDataFromTimeout: (options: TimeoutTriggerCreateOptions) => [import("../atoms").Data, import("..").TriggerDataMediator, import("..").TriggerMediatorOptions, import("../atoms").DataTrigger, import("../atoms").TriggerController]; export declare const createMutationFromTimeout: (options: TimeoutTriggerCreateOptions) => [import("../atoms").Mutation, import("..").TriggerMutationMediator, import("..").TriggerMediatorOptions, import("../atoms").MutationTrigger, import("../atoms").TriggerController]; /************************************************************************************************************************ * * ObservableTrigger creators * ************************************************************************************************************************/ /** * */ interface ObservableTriggerCreateOptions { observable: Observable; autoStart?: boolean; handler?: (arg: V, ...args: any[]) => R; } /** * @param options.observable Observable(Rx) * @param [options.autoStart = true] indicate if the Observable will be subscribed automatically * @param [options.handler = asIs] will be apply to emitted value of Observable before it passed to trigger */ export declare const createObservableTrigger: (options: ObservableTriggerCreateOptions) => Trigger; export declare const createDataFromObservable: (options: ObservableTriggerCreateOptions) => [import("../atoms").Data, import("..").TriggerDataMediator, import("..").TriggerMediatorOptions, import("../atoms").DataTrigger, import("../atoms").TriggerController]; export declare const createMutationFromObservable: (options: ObservableTriggerCreateOptions) => [import("../atoms").Mutation, import("..").TriggerMutationMediator, import("..").TriggerMediatorOptions, import("../atoms").MutationTrigger, import("../atoms").TriggerController]; /************************************************************************************************************************ * * normal function trigger creators * ************************************************************************************************************************/ /** * */ declare type emitFunction

= (...args: [...P]) => void; interface FunctionTriggerCreateOptions

{ agent: (emitFunction: emitFunction<[...P]>) => void; autoBind?: boolean; autoStart?: boolean; handler?: (...args: [...P]) => R; } /** * @param options.agent which takes emitFunction as argument, it will execute in create process * @param [options.autoStart = true] indicate if the shouldEmit will be set to true initially * @param [options.handler = asIs] will be apply to emitted value of emitFunction before it passed to trigger * @example * ```ts * // slow usecase * // first create an emit variable which used to hold the real emit function, * // we can separately call this function to emit values to our trigger later * let emit * * // then we create an agent function, which takes an inner emit function as 1st argument, * // and internally assign the inner emit function to the emit variable which we created in last step * const agent = (innerEmit) => { * emit = innerEmit * } * * // then create a trigger, specify the agent function * // and the handler function which will be called with the arguments passed to emit function later * // the return value will be passed to the trigger * const trigger = createFunctionTrigger({ agent, handler: (score) => score + 1 }) * * // call the emit function which hold be the pre-declared variable * // the trigger will emit 100 (which equals to `99 + 1`) * emit(99) * * // quick usecase * // create all we need using the `createFunctionTriggerAgent` function * // only need to specify the handler function * const agent = createFunctionTriggerAgent((score: number) => score + 1) * * // then pass the created agent to the FunctionTrigger creator using the spread operator * const const trigger = createFunctionTrigger({ ...agent }) * * // call the emit function hold by `agent` to trigger value * agent.emit(99) * ``` */ export declare const createFunctionTrigger:

(options: FunctionTriggerCreateOptions) => Trigger; export declare const createDataFromFunction:

(options: FunctionTriggerCreateOptions) => [import("../atoms").Data, import("..").TriggerDataMediator, import("..").TriggerMediatorOptions, import("../atoms").DataTrigger, import("../atoms").TriggerController]; export declare const createMutationFromFunction:

(options: FunctionTriggerCreateOptions) => [import("../atoms").Mutation, import("..").TriggerMutationMediator, import("..").TriggerMediatorOptions, import("../atoms").MutationTrigger, import("../atoms").TriggerController]; interface FunctionTriggerAgent

{ agent: (emitFunction: emitFunction<[...P]>) => void; handler: (...args: [...P]) => R; emit?: emitFunction<[...P]> | undefined; isBound: boolean; } /** * Function Trigger Agent is designed to be passed to `createFunctionTrigger` function * as part of its options. * * @example * ```js * createFunctionTrigger({ ...createFunctionTriggerAgent(handler), ...otherOptions }) * ``` */ export declare const createFunctionTriggerAgent:

(handler: (...args_0: P) => R) => FunctionTriggerAgent<[...P], R>; export {}; //# sourceMappingURL=derive-create.helpers.d.ts.map