diff --git a/README.md b/README.md index c8b3ba5..514eca6 100644 --- a/README.md +++ b/README.md @@ -57,23 +57,6 @@ export function RunnerName() { } ``` -### `useReplicantOnce` - -- Reads specified replicant value once, without subscribing to it. -- Uses `readReplicant` internally. -- Returns single value that will be updated once when it reads the value -- Does NOT subscribe to replicant value changes - -```tsx -import {useReplicantOnce} from 'use-nodecg'; - -// Only reads the replicant value once and doesn't update -export function RunnerName() { - const count = useReplicantOnce('counter'); - return <div>{count}</div>; -} -``` - ### `useListenFor` - Subscribes messages with `listenFor`, and unlistens on unmount. diff --git a/src/index.ts b/src/index.ts index 9fa9458..228d0f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,2 @@ export * from './use-replicant'; -export * from './use-replicant-once'; export * from './use-listen-for'; diff --git a/src/use-replicant-once.ts b/src/use-replicant-once.ts deleted file mode 100644 index 3781fdb..0000000 --- a/src/use-replicant-once.ts +++ /dev/null @@ -1,23 +0,0 @@ -import {useState} from 'react'; - -export interface UseReplicantOnceOptions { - bundle: string; -} - -export const useReplicantOnce = <T>( - replicantName: string, - initialValue: T, - options?: UseReplicantOnceOptions, -): T | undefined => { - const [state, setState] = useState<T | undefined>(initialValue); - if (options?.bundle) { - nodecg.readReplicant<T>(replicantName, options.bundle, (value) => { - setState(value); - }); - } else { - nodecg.readReplicant<T>(replicantName, (value) => { - setState(value); - }); - } - return state; -};