Mob.Haptic (mob v0.3.5)

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

TypeFeel
:lightBrief, light tap
:mediumStandard tap
:heavyStrong tap
:successSuccess pattern (double tap)
:errorError pattern (triple tap)
:warningWarning pattern (irregular taps)

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

Summary

Functions

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)