Skip to content

Commit

Permalink
fix(signal): VatrRequestSignals global type
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Feb 27, 2022
1 parent 2811104 commit 228e333
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions package/signal/src/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function dispatchSignal<SignalName extends keyof VatrSignals>(
* // dispatch request signal and wait for answer (wait for NEW signal).
* const newContent = await requestSignal('content-change', {foo: 'bar'});
*/
export function requestSignal<SignalName extends keyof VatrSignals>(
export function requestSignal<SignalName extends keyof VatrRequestSignals>(
signalName: SignalName,
requestParam: VatrRequestSignals[SignalName],
): Promise<VatrSignals[SignalName]> {
Expand All @@ -139,14 +139,16 @@ export function requestSignal<SignalName extends keyof VatrSignals>(
* }
* }
*/
export function addSignalProvider<SignalName extends keyof VatrSignals>(
export function addSignalProvider<SignalName extends keyof VatrRequestSignals>(
signalName: SignalName,
signalCallback: ListenerCallback<SignalName>,
signalCallback: (detail: VatrRequestSignals[SignalName]) => void | Promise<void>,
): symbol {
log('addSignalProvider(%s)', signalName);
return addSignalListener(`request-${signalName}` as unknown as SignalName, signalCallback, {
receivePrevious: true,
});
return addSignalListener(
`request-${signalName}` as unknown as SignalName,
signalCallback as unknown as ListenerCallback<SignalName>,
{receivePrevious: true},
);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions package/signal/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ declare global {
/**
* Global request signal parameters types.
*/
type VatrRequestSignals = {
[SignalName in keyof VatrSignals]: unknown;
};
interface VatrRequestSignals {
readonly 'easter-egg': number;
}
}

/**
Expand Down

0 comments on commit 228e333

Please sign in to comment.