From d2bb3b46bce9a11f2a7f0867f0ffb67109a467bb Mon Sep 17 00:00:00 2001 From: Br2850 Date: Tue, 19 Nov 2024 16:06:58 -0500 Subject: [PATCH] add params to timer --- .../src/plugins/SchemaIO/components/TimerView.tsx | 15 +++++++++++---- fiftyone/operators/types.py | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/packages/core/src/plugins/SchemaIO/components/TimerView.tsx b/app/packages/core/src/plugins/SchemaIO/components/TimerView.tsx index 6980c500e35..b098c02035e 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/TimerView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/TimerView.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef } from "react"; +import { useEffect, useRef } from "react"; import { usePanelEvent } from "@fiftyone/operators"; import { usePanelId } from "@fiftyone/spaces"; import { ViewPropsType } from "../utils/types"; @@ -8,6 +8,7 @@ export type TimerViewParams = { on_timeout?: string; interval?: number; timeout?: number; + params?: object; }; class Timer { @@ -47,7 +48,13 @@ class TimeoutTimer extends Timer { function useTimer(params: TimerViewParams) { const panelId = usePanelId(); const triggerEvent = usePanelEvent(); - const { on_interval, interval, timeout, on_timeout } = params; + const { + on_interval, + interval, + timeout, + on_timeout, + params: operator_params, + } = params; const ref = useRef(null); useEffect(() => { @@ -64,7 +71,7 @@ function useTimer(params: TimerViewParams) { if (on_interval) { triggerEvent(panelId, { operator: on_interval, - params: {}, + params: operator_params || {}, prompt: null, }); } @@ -73,7 +80,7 @@ function useTimer(params: TimerViewParams) { if (on_timeout) { triggerEvent(panelId, { operator: on_timeout, - params: {}, + params: operator_params || {}, prompt: null, }); } diff --git a/fiftyone/operators/types.py b/fiftyone/operators/types.py index 50924b56d2e..6a873b03d0a 100644 --- a/fiftyone/operators/types.py +++ b/fiftyone/operators/types.py @@ -2814,6 +2814,7 @@ class TimerView(View): interval (None): the interval in milliseconds to wait before executing the operator on_timeout (None): the operator to execute when the timeout is reached on_interval (None): the operator to execute at the interval + params (None): the params passed to the on_interval or on_timeout operator """ def __init__(self, **kwargs):