@empathyco/x-components
Version:
Empathy X Components
73 lines (34 loc) • 1.3 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [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)<!-- --><ToPayload>
</td><td>
The wire which the new Wire is created from.
</td></tr>
<tr><td>
mapFn
</td><td>
(payload: FromPayload) => ToPayload
</td><td>
Function to map the payload from `FromPayload` to `ToPayload`<!-- -->.
</td></tr>
</tbody></table>
**Returns:**
[Wire](./x-components.wire.md)<!-- --><FromPayload>
A new [Wire](./x-components.wire.md)<!-- -->.