diff --git a/.changeset/lucky-weeks-nail.md b/.changeset/lucky-weeks-nail.md
new file mode 100644
index 000000000..1f967bdb4
--- /dev/null
+++ b/.changeset/lucky-weeks-nail.md
@@ -0,0 +1,5 @@
+---
+'@ice/runtime': patch
+---
+
+feat: add suspense event dispatch in Suspense component
diff --git a/packages/runtime/src/Suspense.tsx b/packages/runtime/src/Suspense.tsx
index 86866662c..b187aaf0a 100644
--- a/packages/runtime/src/Suspense.tsx
+++ b/packages/runtime/src/Suspense.tsx
@@ -126,6 +126,11 @@ interface SuspenseProps {
[key: string]: any;
}
+function dispatchSuspenseEvent(event: string, id: string) {
+ window.dispatchEvent(new CustomEvent(event, { detail: { id } }));
+}
+const DISPATCH_SUSPENSE_EVENT_STRING = dispatchSuspenseEvent.toString();
+
export function withSuspense(Component) {
return (props: SuspenseProps) => {
const { fallback, id, ...componentProps } = props;
@@ -153,10 +158,22 @@ export function withSuspense(Component) {
return (
+
+
+
);
};
@@ -174,3 +191,20 @@ function Data(props) {
/>
);
}
+
+interface InlineScriptProps {
+ id: string;
+ script: string;
+}
+
+function InlineScript(props: InlineScriptProps) {
+ return (
+
+ );
+}
\ No newline at end of file