Module: hooks/third-party-apps-path
Table of contents
Functions
Functions
useThirdPartyAppsPath
▸ useThirdPartyAppsPath(): void
A React hook that manages the path of third-party applications.
It subscribes to the relevant IPC (Inter-Process Communication) channel to listen for updates on the path,
and updates the state atom thirdPartyAppsPathAtom
whenever a new path is received.
This hook subscribes to IPC messages upon mounting, and unsubscribes on unmounting to clean up the event listener.
It uses the buildKey
function to generate specific keys for the IPC messages based on the ID.THIRD_PARTY_APPS
enum.
Returns
void
This hook does not return a value; it solely operates side effects to manage state.
Requires
thirdPartyAppsPathAtom - An atom from Jotai to manage the state of the third-party apps path.
Requires
buildKey - A function to generate IPC message keys based on identifiers and optional suffixes.
Requires
ID - An enumeration used to specify different IPC identifiers.
Effects
- Subscribes to the IPC channel
buildKey([ID.THIRD_PARTY_APPS], { suffix: 'path' })
to receive updates on the path. - Sends an IPC message using
buildKey([ID.THIRD_PARTY_APPS], { suffix: 'get-path' })
to request the current path. - Automatically updates the
thirdPartyAppsPathAtom
state when a new path is broadcasted. - Ensures clean-up by unsubscribing from the IPC channel when the component unmounts.