Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/documentation #27

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/shared/hooks/interfaces/useDevicePresetsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DevicePresetsState, PresetChannel, useGetDevice } from 'src/lib';
import { useWebsocketContext } from 'src/lib/utils';


export function useIDevicePresetsModel(key: string): IDevicePresetsModelProps | undefined {
export function useDevicePresetsModel(key: string): DevicePresetsModelProps | undefined {
const { sendMessage } = useWebsocketContext();
const state = useGetDevice<DevicePresetsState>(key);
const path = `/device/${key}`;
Expand All @@ -21,7 +21,7 @@ export function useIDevicePresetsModel(key: string): IDevicePresetsModelProps |
return { state, recallPreset, savePresets };
}

export interface IDevicePresetsModelProps {
export interface DevicePresetsModelProps {
state: DevicePresetsState;
recallPreset: (deviceKey: string, preset: PresetChannel) => void;
savePresets: (presets: PresetChannel[]) => void;
Expand Down
19 changes: 19 additions & 0 deletions src/lib/shared/hooks/usePressHoldRelease.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import { useRef } from 'react';


/**
* This hook is used to link up the functions to trigger for a button that can be pressed and held
* @param onPress function to call when the pointer is pressed
* @param onRelease function to call when the pointer is released
* @param onHold function to call when the pointer is held
* @param holdTimeMs time in milliseconds to hold before onHold is called
* @returns an object that can be easily applied to a button or other element using a spread operator to attach to the element events
* @example
* const button1 = usePressHoldRelease({
* onPress: () => console.log('pressed'),
* onRelease: () => console.log('released'),
* onHold: () => console.log('held'),
* holdTimeMs: 2000
* });
*
* // use the spread operator to attach the events to the button
* <button {...button1}>Press and Hold</button>
*/
export function usePressHoldRelease({
onPress,
onRelease,
Expand Down
Loading