Dala.Haptic (dala v0.0.1)

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
  Dala.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(Dala.Socket.t(), atom()) :: Dala.Socket.t()

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

Dala.Haptic.trigger(socket, :light)