Skip to content


The timer task handler allows creating simple timers.

Task: Default

This task describes a timer and the action that should be dispatched at the specified interval.

  type: 'timer',
  interval: number, // time in ms at which the tick action should be dispatched
  actions: {
    tick: string    // action type to dispatch when the number has been generated


To stop a timer, simply remove the task (see how in the example).


Event Type Meta Payload
tick None None


Run this example »

import {
  addTask, delTasks, reduceReducers, taskReducer
} from 'redux-agent'

const reducer = (state, action) => {
  switch (action.type) {
    case 'START_TIMER':
      return addTask(state, {
        type: 'timer',
        interval: 500,
        actions: {
          tick: 'TICK'

    case 'TICK':
      return {
        counter: state.counter + 1

    case 'STOP_ALL_TIMERS':
      return delTasks(state,
        (t) => t.type === 'timer')

      return state

export default reduceReducers(reducer, taskReducer)