UNPKG

@empathyco/x-components

Version:
73 lines (34 loc) 1.3 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 <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> toWire </td><td> [Wire](./x-components.wire.md)<!-- -->&lt;ToPayload&gt; </td><td> The wire which the new Wire is created from. </td></tr> <tr><td> mapFn </td><td> (payload: FromPayload) =&gt; ToPayload </td><td> Function to map the payload from `FromPayload` to `ToPayload`<!-- -->. </td></tr> </tbody></table> **Returns:** [Wire](./x-components.wire.md)<!-- -->&lt;FromPayload&gt; A new [Wire](./x-components.wire.md)<!-- -->.