summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/contexts/StreamingContext.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/contexts/StreamingContext.tsx')
-rw-r--r--packages/cli/src/ui/contexts/StreamingContext.tsx26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/cli/src/ui/contexts/StreamingContext.tsx b/packages/cli/src/ui/contexts/StreamingContext.tsx
new file mode 100644
index 00000000..6144ed70
--- /dev/null
+++ b/packages/cli/src/ui/contexts/StreamingContext.tsx
@@ -0,0 +1,26 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import React, { createContext } from 'react';
+import { StreamingState } from '../types.js';
+
+export interface StreamingContextType {
+ streamingState: StreamingState;
+}
+
+export const StreamingContext = createContext<StreamingContextType | undefined>(
+ undefined,
+);
+
+export const useStreamingContext = (): StreamingContextType => {
+ const context = React.useContext(StreamingContext);
+ if (context === undefined) {
+ throw new Error(
+ 'useStreamingContext must be used within a StreamingContextProvider',
+ );
+ }
+ return context;
+};