Search documentation of mob

# Mob.Haptic (mob v0.6.18)

Copy Markdown View Source

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`.

## Summary

### Functions

trigger(socket, type)

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

## Functions

# trigger(socket, type)

    @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)