Line data Source code
1 : import * as React from 'react';
2 :
3 : import type { ComputeQueryExecution } from './computation_tasks.js';
4 : import type { TaskVariant } from './computation_types.js';
5 :
6 : export type CreateComputeQueryExecution = (task: TaskVariant) => ComputeQueryExecution;
7 :
8 1 : const COMPUTE_QUERY_EXECUTION_CTX = React.createContext<CreateComputeQueryExecution | null>(null);
9 :
10 1 : export function ComputeQueryExecutionProvider(props: React.PropsWithChildren<{ createExecution: CreateComputeQueryExecution }>) {
11 1 : return (
12 1 : <COMPUTE_QUERY_EXECUTION_CTX.Provider value={props.createExecution}>
13 1 : {props.children}
14 1 : </COMPUTE_QUERY_EXECUTION_CTX.Provider>
15 : );
16 1 : }
17 :
18 1 : export function useCreateComputeQueryExecution(): CreateComputeQueryExecution | null {
19 1 : return React.useContext(COMPUTE_QUERY_EXECUTION_CTX);
20 1 : }
|