Skip to content

Commit

Permalink
Add addStatusHandler/removeStatusHandler to hot API (vercel#2565)
Browse files Browse the repository at this point in the history
* Add addStatusHandler/removeStatusHandler to hot API

* Update snapshots
  • Loading branch information
alexkirsz authored Nov 3, 2022
1 parent a0f74f2 commit cd81a90
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 2 deletions.
4 changes: 4 additions & 0 deletions crates/turbopack-ecmascript/js/src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,10 @@
// implement, but the Next.js React Refresh runtime uses this to decide
// whether to schedule an update.
status: () => "idle",

// NOTE(alexkirsz) Since we always return "idle" for now, these are no-ops.
addStatusHandler: (_handler) => {},
removeStatusHandler: (_handler) => {},
};

return { hot, hotState };
Expand Down
8 changes: 6 additions & 2 deletions crates/turbopack-ecmascript/js/types/hot.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const enum HotUpdateStatus {
idle = "idle",
}

export type HotUpdateStatusHandler = (status: HotUpdateStatus) => void;

export interface HotData {
prevExports?: Exports;
}
Expand Down Expand Up @@ -37,8 +39,6 @@ export interface Hot {
active: boolean;
data: HotData;

status: () => keyof typeof HotUpdateStatus;

accept: AcceptFunction;

decline: (module?: string | string[]) => void;
Expand All @@ -50,4 +50,8 @@ export interface Hot {
removeDisposeHandler: (callback: (data: object) => void) => void;

invalidate: () => void;

status: () => keyof typeof HotUpdateStatus;
addStatusHandler: (handler: HotUpdateStatusHandler) => void;
removeStatusHandler: (handler: HotUpdateStatusHandler) => void;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd81a90

Please sign in to comment.