Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Redux Toolkit · Function

isAllOf

isAllOf creates a type-safe matcher that succeeds only when every supplied action creator or type guard matches the same value. The returned matcher can be used in reducers, middleware, or other TypeScript code.

How it works

isAllOf accepts one or more action creators or type guards and returns a new type guard. The returned function succeeds only when every supplied matcher accepts the same value, while preserving TypeScript narrowing for the matched result.

Syntax

isAllOf(...matchers)

Parameters

NameTypeDescription
matchersActionCreator | TypeGuard | CustomActionCreatorOne or more Redux Toolkit action creators, type guard functions, or custom action creators whose .match property is a type guard.

Returns

A type guard function that returns true when all supplied matcher functions match the input.

Key points

  • isAllOf takes one or more matcher functions rather than the value to test immediately.
  • Supported action creators include those generated by Redux Toolkit APIs such as createAction, createSlice, and createAsyncThunk.
  • Plain TypeScript type guards are valid inputs, so matching can combine Redux action creators with application-specific predicates.
  • Custom action creators are supported when their .match property provides a type guard.
  • The resulting function can narrow types in ordinary TypeScript code, not only in Redux reducer builder APIs.

Common mistakes

  • The returned matcher requires every supplied condition to accept the same value; it does not implement an either/or check.

Example: Require every matcher to match

import { createAction, isAllOf } from '@reduxjs/toolkit'

const saved = createAction<{ id: string }>('items/saved')
const synced = createAction<{ id: string }>('items/synced')

const isSavedAndSynced = isAllOf(saved, synced)

console.log(isSavedAndSynced(saved({ id: 'a' })))
// false: one action cannot match both action creators

This matcher is intentionally false for distinct action creators; use it when multiple supplied type guards can all describe the same value.

When to use it

Combine multiple conditions in addMatcher

A reducer builder needs one predicate for a value that must satisfy several action-related conditions.

Filter middleware actions

Middleware needs to recognize an action only when every supplied type guard agrees.

Narrow values with TypeScript

Application code needs a reusable predicate that both checks and narrows an action value.

Interview questions

QWhat does isAllOf do?

isAllOf is a higher-order matcher: it receives one or more action creators or type guards and returns a type guard. That returned guard is true only when all supplied matchers match the input.

Follow-up: How would you match an action satisfying at least one condition? Use isAnyOf instead, whose returned matcher succeeds when any supplied matcher matches.

QWhat kinds of matchers can isAllOf accept?

Its inputs can include Redux Toolkit action creators from createAction, createSlice, or createAsyncThunk, plus type guards and custom action creators with a .match type guard. This lets the same matcher work across standard and custom action definitions.

Follow-up: Why can a custom action creator participate? Because exposing .match as a type guard gives the matcher a supported way to test the action and narrow its type.

QCan the returned matcher be used outside reducers?

The returned function is also usable as a TypeScript type guard outside reducer matcher callbacks. That makes it useful wherever code needs to test and narrow a value against several action conditions.

Follow-up: Where are these utilities commonly used? They are especially useful with builder.addMatcher in createSlice or createReducer and in custom middleware.

  • isAnyOf
  • createAction
  • createSlice
  • createAsyncThunk
  • builder.addMatcher
  • createReducer
  • custom middleware

Source: Matching Utilities. Checked 2026-10-15.