Skip to content

Commit

Permalink
Throttle submit instead of debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelemeny committed Feb 19, 2024
1 parent 152c274 commit d63aae3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/QueryEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css } from '@emotion/css';

import React, { createContext } from 'react';
import { debounceTime } from 'rxjs';
import { debounceTime, throttleTime } from 'rxjs';
import { useObservableCallback, useSubscription } from 'observable-hooks'

import { CoreApp, Field, getDefaultTimeRange, GrafanaTheme2, QueryEditorProps } from '@grafana/data';
Expand Down Expand Up @@ -100,7 +100,7 @@ const QueryEditorForm = ({ value, onRunQuery }: Props) => {
}

const [onChangeCB, textChanged$] = useObservableCallback<string>(event$ => event$.pipe(debounceTime(1000)))
const [onSubmitCB, submitted$] = useObservableCallback<string>(event$=>event$.pipe(debounceTime(500)))
const [onSubmitCB, submitted$] = useObservableCallback<string>(event$=>event$.pipe(throttleTime(500)))

useSubscription(textChanged$, onChange)
useSubscription(submitted$, onSubmit)
Expand Down

0 comments on commit d63aae3

Please sign in to comment.