Sawtaytoes
9/20/2018 - 2:49 AM

Flic Button listener for a single button press.

Flic Button listener for a single button press.

import {
    BUTTON_DOWN,
    singlePressAction,
} from './actions'

const handleButtonPress = buttonState => (
    buttonState === BUTTON_DOWN
    && singlePressAction()
)

const listenForButtonPress = bluetoothAddress => {
    new FlicConnectionChannel(bluetoothAddress)
    .on('buttonUpOrDown', handleButtonPress)
}