Skip to content

Latest commit

 

History

History
263 lines (164 loc) · 10.8 KB

README.md

File metadata and controls

263 lines (164 loc) · 10.8 KB

My Capacitor Plugin 🔌

The readme file can be formatted however you'd like. Just insert the docgen placeholder elements where the index of the API methods, and the API docs should go.

Below is an index of all the methods available.

Custom Readme Content

Manage your readme content however, and on every docgen rebuild it will leave the original content as is, but update the inner text of the docgen placeholder elements with the updated generated docs.

Docs from JSDoc comments!

This content is from the JSDOC comments on top of the HapticsPlugin interface. All the API data below is generated from comments from its methods, interfaces and enums.

Take a look at the test HapticsPlugin interface source file.

impact(...)

impact(options: HapticsImpactOptions, x?: number | undefined) => Promise<HapticsImpact>

Trigger a haptics "impact" feedback

Param Type Description
options HapticsImpactOptions The impact options
x number

Returns: Promise<HapticsImpact>

Since: 1.0.0


notification(...)

notification(options?: HapticsNotificationOptions | undefined) => Promise<string | number>

Trigger a haptics "notification" feedback

Param Type
options HapticsNotificationOptions

Returns: Promise<string | number>

Since: 1.0.0


vibrate(...)

vibrate(options?: VibrateOptions | undefined) => Promise<number>

Vibrate the device

Param Type
options VibrateOptions

Returns: Promise<number>

Since: 1.0.0


addListener('vibrate', ...)

addListener(eventName: 'vibrate', listenerFunc: VibrateListener) => Promise<void>

Add a listener. Callback has VibrateOptions.

Param Type
eventName 'vibrate'
listenerFunc VibrateListener

Since: 1.0.0


removeAllListeners()

removeAllListeners() => void

Remove all the listeners that are attached to this plugin

Since: 1.0.0


Interfaces

HapticsImpact

Prop Type
value number

HapticsImpactOptions

Prop Type Description Default Since
style HapticsImpactStyle Impact Feedback Style The mass of the objects in the collision simulated by a UIImpactFeedbackGenerator object. Type is a HapticsImpactStyle. HapticsImpactStyle.Heavy 1.0.0
value boolean
recursive HapticsImpactOptions

HapticsNotificationOptions

Prop Type Description Default Since
type HapticsNotificationType Notification Feedback Type The type of notification feedback generated by a UINotificationFeedbackGenerator object. HapticsNotificationType.SUCCESS 1.0.0

VibrateOptions

Prop Type Description Default Since
duration number Duration of the vibration in milliseconds. Not supported in iOS. 300 1.0.0

VibrateListenerEvent

Prop Type Description Since
style HapticsImpactStyle The style of vibration. 1.0.0
duration number The duration of the vibration. 1.0.0
repeat RepeatSchedule How often this vibrate event is repeated. 1.0.0

Type Aliases

VibrateListener

The vibrate listener callback function.

(event: VibrateListenerEvent): void

RepeatSchedule

How often a vibration repeats.

'hourly' | 'daily' | 'weekly' | 'monthly'

Enums

HapticsImpactStyle

Members Value Description Since
Heavy 'HEAVY' A collision between small, light user interface elements 1.0.0
Medium 'MEDIUM' A collision between moderately sized user interface elements 1.0.0
Light 'LIGHT' A collision between small, light user interface elements 1.0.0

HapticsNotificationType

Members Value Description Since
SUCCESS 'SUCCESS' A notification feedback type indicating that a task has completed successfully 1.0.0
WARNING 'WARNING' A notification feedback type indicating that a task has produced a warning 1.0.0
ERROR 'ERROR' A notification feedback type indicating that a task has failed 1.0.0

Haptics Plugin Config

Haptics can be configured with this options:

Prop Type Description Default Since
style 'none' | 'native' Configure the style. native 1.0.0
duration number Configure the duration. 1.2.3

Examples

In capacitor.config.json:

{
  "plugins": {
    "Haptics": {
      "style": "native",
      "duration": 123
    }
  }
}

In capacitor.config.ts:

/// <reference types="@capacitor/haptics" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    Haptics: {
      style: "native",
      duration: 123,
    },
  },
};

export default config;

Commit Your Readme 🚀

The benefit of this readme file is that is also acts as the landing page for the Github repo and NPM package, and the anchors within the docs can also be linked to and shared.