UNPKG

@empathyco/x-components

Version:
96 lines 4.41 kB
import type { XModuleName } from '../x-modules/x-modules.types'; import type { TimedWireOperatorOptions, TimeSelector, Wire, WireParams } from './wiring.types'; /** * Creates a {@link Wire} that is only executed whenever the condition in the filterFn is true. * * @param wire - The wire to filter. * @param filterFn - A function which must return a boolean and that will be executed every time * the wire is called. * @returns The Wire function filter. * * @public */ export declare function filter<Payload>(wire: Wire<Payload>, filterFn: (parameters: WireParams<Payload>) => boolean): Wire<Payload>; /** * Creates a {@link Wire} that is only executed when the payload is truthy. A truthy value is * whatever is not a {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy | falsy value}. * * @param wire - The wire to avoid executing when the payload is falsy. * @returns The Wire function falsy filter. * * @public */ export declare function filterFalsyPayload<Payload>(wire: Wire<Exclude<Payload, null | undefined | false | 0 | ''>>): Wire<Payload>; /** * Creates a {@link Wire} that is only executed when the payload is a * {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy | falsy value}. * * @param wire - The wire to avoid executing when the payload is truthy. * @returns The Wire function truthy filter. * * @public */ export declare function filterTruthyPayload<Payload>(wire: Wire<Payload>): Wire<Payload>; /** * Creates a {@link Wire} that is only executed if the event is emitted from a {@link XModule} * that is included * in the `whitelist` array passed as parameter. * * @param wire - The wire to filter using the whitelist. * @param whitelist - An array of {@link XModuleName} or null. * @returns The Wire function with whitelisted modules filter. * * @public */ export declare function filterWhitelistedModules<Payload>(wire: Wire<Payload>, whitelist: Array<XModuleName | null>): Wire<Payload>; /** * Creates a {@link Wire} that is only executed if the event is emitted from a {@link XModule} * that is NOT included * in the `blacklist` array passed as parameter. * * @param wire - The wire to filter using the whitelist. * @param blacklist - An array of {@link XModuleName} or null. * @returns The Wire function with blacklisted modules filter. * * @public */ export declare function filterBlacklistedModules<Payload>(wire: Wire<Payload>, blacklist: Array<XModuleName | null>): Wire<Payload>; /** * Creates a debounced {@link Wire}. Being debounced means that it will only be executed after * the time given by `timeInMs` has passed without invoking it. * * @param wire - The wire to debounce. * @param timeInMs - The time in milliseconds to debounce the wire execution or a function to * retrieve it from the store. * @param options - Options to configure this wire with, like an event to force it or cancel it. * @returns The Wire function with a debounced timing. * * @public */ export declare function debounce<Payload>(wire: Wire<Payload>, timeInMs: TimeSelector | number, options?: TimedWireOperatorOptions): Wire<Payload>; /** * Creates a throttled {@link Wire}. Being throttled means that it will only be executed once * every couple of milliseconds given by the `timeInMs` parameter. * * @param wire - The wire to throttle. * @param timeInMs - The time in milliseconds to throttle the wire execution or a function to * retrieve it from the store. * @param options - Options to configure this wire with, like an event to force it or cancel it. * @returns The Wire function with a throttle timing. * * @public */ export declare function throttle<Payload>(wire: Wire<Payload>, timeInMs: TimeSelector | number, options?: TimedWireOperatorOptions): Wire<Payload>; /** * Creates a {@link Wire} from other `toWire` wire. It uses `mapFn` to transform the * `FromPayload` received to `ToPayload` which `toWire` requires. This is * useful to reuse wires in different Events where the payload doesn't fit exactly. * * @param toWire - The wire which the new Wire is created from. * @param mapFn - Function to map the payload from `FromPayload` to `ToPayload`. * @returns A new {@link Wire}. * * @public */ export declare function mapWire<FromPayload, ToPayload>(toWire: Wire<ToPayload>, mapFn: (payload: FromPayload) => ToPayload): Wire<FromPayload>; //# sourceMappingURL=wires.operators.d.ts.map