@empathyco/x-components
Version:
Empathy X Components
28 lines (16 loc) • 1.13 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
| Parameter | Type | Description |
| --- | --- | --- |
| toWire | [Wire](./x-components.wire.md)<!-- --><ToPayload> | The wire which the new Wire is created from. |
| mapFn | (payload: FromPayload) => ToPayload | Function to map the payload from <code>FromPayload</code> to <code>ToPayload</code>. |
**Returns:**
[Wire](./x-components.wire.md)<!-- --><FromPayload>
A new [Wire](./x-components.wire.md)<!-- -->.