# `Mob.Haptic`
[🔗](https://github.com/genericjam/mob/blob/main/lib/mob/haptic.ex#L1)

Haptic feedback. No permission required on either platform.

## Usage

    # In a handle_event or handle_info:
    def handle_event("purchase", _params, socket) do
      Mob.Haptic.trigger(socket, :success)
      {:noreply, socket}
    end

## Feedback types

| Type       | Feel                              |
|------------|-----------------------------------|
| `:light`   | Brief, light tap                  |
| `:medium`  | Standard tap                      |
| `:heavy`   | Strong tap                        |
| `:success` | Success pattern (double tap)      |
| `:error`   | Error pattern (triple tap)        |
| `:warning` | Warning pattern (irregular taps)  |

iOS uses `UIImpactFeedbackGenerator` / `UINotificationFeedbackGenerator`.
Android uses `View.performHapticFeedback` with `HapticFeedbackConstants`.

# `trigger`

```elixir
@spec trigger(Mob.Socket.t(), atom()) :: Mob.Socket.t()
```

Fire a haptic feedback pulse. Returns the socket unchanged so it can be
used inline without disrupting the handle_event return value.

    Mob.Haptic.trigger(socket, :light)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
