UNPKG

@empathyco/x-components

Version:
28 lines (16 loc) 1.13 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [mapWire](./x-components.mapwire.md) ## mapWire() function Creates a [Wire](./x-components.wire.md) 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. **Signature:** ```typescript export declare function mapWire<FromPayload, ToPayload>(toWire: Wire<ToPayload>, mapFn: (payload: FromPayload) => ToPayload): Wire<FromPayload>; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | toWire | [Wire](./x-components.wire.md)<!-- -->&lt;ToPayload&gt; | The wire which the new Wire is created from. | | mapFn | (payload: FromPayload) =&gt; ToPayload | Function to map the payload from <code>FromPayload</code> to <code>ToPayload</code>. | **Returns:** [Wire](./x-components.wire.md)<!-- -->&lt;FromPayload&gt; A new [Wire](./x-components.wire.md)<!-- -->.