Skip to content

Commit

Permalink
add params to timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Br2850 committed Nov 19, 2024
1 parent 33fd083 commit d2bb3b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/packages/core/src/plugins/SchemaIO/components/TimerView.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -8,6 +8,7 @@ export type TimerViewParams = {
on_timeout?: string;
interval?: number;
timeout?: number;
params?: object;
};

class Timer {
Expand Down Expand Up @@ -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<Timer | null>(null);

useEffect(() => {
Expand All @@ -64,7 +71,7 @@ function useTimer(params: TimerViewParams) {
if (on_interval) {
triggerEvent(panelId, {
operator: on_interval,
params: {},
params: operator_params || {},
prompt: null,
});
}
Expand All @@ -73,7 +80,7 @@ function useTimer(params: TimerViewParams) {
if (on_timeout) {
triggerEvent(panelId, {
operator: on_timeout,
params: {},
params: operator_params || {},
prompt: null,
});
}
Expand Down
1 change: 1 addition & 0 deletions fiftyone/operators/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d2bb3b4

Please sign in to comment.