Example Usage

import zero_true as zt
import time

# Initialize state
zt_state = zt.state()
zt_state.setdefault('timer_triggered', 0)

# Create a Timer component
timer = zt.Timer(
  id="sample_timer",
  interval=1000,  # Interval in milliseconds (5000ms = 5s)
  triggerEvent='interval',  # Trigger event based on the interval
  value=True # Start the timer
)


# Create a Text component to display the timer's current second
timer_text = zt.Text(
  id="timer_text",
  text= f"Timer Interval is: {timer.interval}",
  color="primary"
)

# Layout including the Timer component
layout = zt.Layout(rows=[
  zt.Row(components=[timer_text.id])
])

if timer.value:
  timer_text = "Interval Passed!"

Example Output

Overview

pydantic model zero_true.Timer

The Timer component is designed to handle periodic execution of code at specified intervals, providing a robust mechanism for time-based operations without any visual output. This functionality is crucial for applications that require regular updates or checks, such as data polling, automatic refresh, or scheduled tasks. The component is configured via an interval set in milliseconds and can be triggered by specific events, offering precise control over timing operations within web applications.

JSON Schema

Bellow are the various attributes you can assign to the component. Utlizing them can allow for modifications to the pre-created object.
zero_true.Timer
Zero True Component

Methods

classmethod get_value_from_global_state(value, values)