Skip to content

Commit

Permalink
Deserialized types (deephaven#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Jun 18, 2024
1 parent 2c856b2 commit a65fc40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ export type SerializedFocusEventCallback = (
event: SerializedFocusEvent
) => void;

export type DeserializedFocusEventCallback = (e: FocusEvent) => void;

/**
* Get a callback function to be passed into spectrum components
* @param callback FocusEvent callback to be called with the serialized event
* @returns A callback to be passed into the Spectrum component that transforms the event and calls the provided callback
*/
export function useFocusEventCallback(
callback?: SerializedFocusEventCallback
): (e: FocusEvent) => void {
): DeserializedFocusEventCallback {
return useCallback(
(e: FocusEvent) => {
callback?.(serializeFocusEvent(e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ export type SerializedKeyboardEventCallback = (
event: SerializedKeyboardEvent
) => void;

export type DeserializedKeyboardEventCallback = (e: KeyboardEvent) => void;

/**
* Get a callback function to be passed into spectrum components
* @param callback KeyboardEvent callback to be called with the serialized event
* @returns A callback to be passed into the Spectrum component that transforms the event and calls the provided callback
*/
export function useKeyboardEventCallback(
callback?: SerializedKeyboardEventCallback
): (e: KeyboardEvent) => void {
): DeserializedKeyboardEventCallback {
return useCallback(
(e: KeyboardEvent) => {
callback?.(serializeKeyboardEvent(e));
Expand Down

0 comments on commit a65fc40

Please sign in to comment.