Object whose values are action creator functions.
An action creator of type T
whose payload
type could not be inferred. Accepts everything as payload
.
An action creator of type T
that takes an optional payload of type P
.
An action creator of type T
that takes no payload.
An action creator of type T
that requires a payload of type P.
An action creator that takes multiple arguments that are passed
to a PrepareAction
method to create the final Action.
A builder for an action <-> reducer map.
An Action type which accepts any other properties.
This is mainly for the use of the Reducer
type.
This is not part of Action
itself to prevent types that extend Action
from
having an index signature.
Object containing action creators for handling asynchronous actions.
Used to implement the buffering strategy for a channel. The Buffer interface
defines 3 methods: isEmpty
, put
and take
A channel is an object used to send and receive messages between tasks. Messages from senders are queued until an interested receiver request a message, and registered receiver is queued until a message is available.
A reducer that allows for slices/reducers to be injected after initialisation.
Options for configureStore()
.
Options for createSlice()
.
A dispatching function (or simply dispatch function) is a function that accepts an action or an async action; it then may or may not dispatch one or more actions to the store.
Options for createImmutableStateInvariantMiddleware()
.
Gets notified with synchronous and asynchronous errors raised by listeners
or predicates
.
A middleware is a higher-order function that composes a dispatch function to return a new dispatch function. It often turns async actions into actions.
Options for createSerializableStateInvariantMiddleware()
.
The return value of createSlice
A store is an object that holds the application's state tree. There should only be a single store in a Redux app, as the composition happens on the reducer level.
A store creator is a function that creates a Redux store. Like with
dispatching function, we must distinguish the base store creator,
createStore(reducer, preloadedState)
exported from the Redux package, from
store creators that are returned from the store enhancers.
The Task interface specifies the result of running a Saga using fork
,
middleware.run
or runSaga
.
The dispatch method as modified by React-Thunk; overloaded so that you can dispatch:
dispatch()
returns the action itselfdispatch()
returns the thunk's return valueAn Action type which accepts any other properties.
This is mainly for the use of the Reducer
type.
This is not part of Action
itself to prevent types that extend Action
from
having an index signature.
Function to remove listener added by Store.subscribe()
.
An action is a plain object that represents an intention to change the state. Actions are the only way to get data into the store. Any data, whether from UI events, network callbacks, or other sources such as WebSockets needs to eventually be dispatched as actions.
Infer action type from a reducer function.
Infer action union type from a ReducersMapObject
.
Defines a mapping from action types to corresponding action object shapes.
Returns the return type of the action creator.
[...A, B] -> A
A type describing the return value of createAsyncThunk
.
Might be useful for wrapping createAsyncThunk
in custom abstractions.
A ThunkAction created by createAsyncThunk
.
Dispatching it returns a Promise for either a
fulfilled or rejected action.
Also, the returned value contains an abort()
method
that allows the asyncAction to be cancelled from the outside.
Options object for createAsyncThunk
.
A type describing the payloadCreator
argument to createAsyncThunk
.
Might be useful for wrapping createAsyncThunk
in custom abstractions.
A type describing the return value of the payloadCreator
argument to createAsyncThunk
.
Might be useful for wrapping createAsyncThunk
in custom abstractions.
A case reducer is a reducer function for a specific action type. Case
reducers can be composed to full reducers using createReducer()
.
Derives the slice's actions
property from the reducers
options
A mapping from action types to case reducers for createReducer()
.
A CaseReducer with a prepare
method.
Convert a readonly type into a mutable type, if possible
A Redux store returned by configureStore()
. Supports dispatching
side-effectful thunks in addition to plain actions.
A minimal observable of state changes. For more information, see the observable proposal: https://github.com/tc39/proposal-observable
An Observer is used to receive data from an Observable, and is supplied as an argument to subscribe.
Represents the actual selectors generated by createSelector
.
An action with a string type and an associated payload. This is the
type of action returned by createAction()
action creators.
An action creator that produces actions with a payload
attribute.
Infer a combined preloaded state shape from a ReducersMapObject
.
A "prepare" method to be used as the second parameter of createAction
.
Takes any number of arguments and returns a Flux Standard Action without
type (will be added later) that must contain a payload (might be undefined).
A reducer is a function that accepts an accumulation and a value and returns a new accumulation. They are used to reduce a collection of values down to a single value
Infer reducer union type from a ReducersMapObject
.
Object whose values correspond to different reducer functions.
A Promise that will never reject.
Annotate return type of generators with SagaIterator
to get strict
type-checking of yielded effects.
A standard selector function.
The type describing a slice's reducers
option.
The type describing a slice's selectors
option.
Infer a combined state shape from a ReducersMapObject
.
A store enhancer is a higher-order function that composes a store creator to return a new, enhanced store creator. This is similar to middleware in that it allows you to alter the store interface in a composable way.
[H, ...T] -> T
A "thunk" action (a callback function that can be dispatched to the Redux store.)
A "pre-typed" version of addListenerAction
, so the listener args are well-typed
A "pre-typed" version of removeListenerAction
, so the listener args are well-typed
A "pre-typed" version of middleware.startListening
, so the listener args are well-typed
A "pre-typed" version of middleware.stopListening
, so the listener args are well-typed
Used on a SliceCaseReducers object.
Ensures that if a CaseReducer is a CaseReducerWithPrepare
, that
the reducer
and the prepare
function use the same type of payload
.
These are private action types reserved by Redux. For any unknown actions, you must return the current state. If the current state is undefined, you must return the initial state. Do not reference these action types directly in your code.
A Redux store enhancer that watches for "low-priority" actions, and delays notifying subscribers until either the queued callback executes or the next "standard-priority" action is dispatched.
Provides some common buffers
"Draft-Safe" version of reselect
's createSelector
:
If an immer
-drafted object is passed into the resulting selector's first argument,
the selector will act on the current draft value, instead of returning a cached value
that might be possibly outdated if the draft has been modified since.
The produce
function takes a value and a "recipe function" (whose
return value often depends on the base state). The recipe function is
free to mutate its first argument however it wants. All mutations are
only ever applied to a copy of the base state.
Accepts one or more "input selectors" (either as separate arguments or a single array), a single "result function" / "combiner", and an optional options object, and generates a memoized selector function.
A function that accepts an initial state, an object full of reducer functions, and a "slice name", and automatically generates action creators and action types that correspond to the reducers and state.
Serializes an error into a plain object. Reworked from https://github.com/sindresorhus/serialize-error
Creates an effect that instructs the middleware to queue the actions matching
pattern
using an event channel. Optionally, you can provide a buffer to
control buffering of the queued actions.
Creates an Effect description that instructs the middleware to run multiple
Effects in parallel and wait for all of them to complete. It's quite the
corresponding API to standard
Promise#all
.
Alias for call([context, fn], ...args)
.
Creates a store enhancer that applies middleware to the dispatch method of the Redux store. This is handy for a variety of tasks, such as expressing asynchronous actions in a concise manner, or logging every action payload.
Turns an object whose values are action creators, into an object with the
same keys, but with every function wrapped into a dispatch
call so they
may be invoked directly. This is just a convenience method, as you can call
store.dispatch(MyActionCreators.doSomething())
yourself just fine.
Creates an Effect description that instructs the middleware to call the
function fn
with args
as arguments.
Creates an Effect description that instructs the middleware to cancel a previously forked task.
Creates an effect that instructs the middleware to return whether this generator has been cancelled. Typically you use this Effect in a finally block to run Cancellation specific code
A factory method that can be used to create Channels. You can optionally pass it a buffer to control how the channel buffers the messages.
Turns an object whose values are different reducer functions, into a single reducer function. It will call every child reducer, and gather their results into a single state object, whose keys correspond to the keys of the passed reducer functions.
Composes single-argument functions from right to left. The rightmost function can take multiple arguments as it provides the signature for the resulting composite function.
A friendly abstraction over the standard Redux createStore()
function.
Creates an Effect description that instructs the middleware to invoke fn
as
a Node style function.
A utility function to create an action creator for the given action type string. The action creator accepts a single argument, which will be included in the action object as a field called payload. The action creator function will also have its toString() overridden so that it returns the action type.
Returns an object with an action creator representing the stages of an async action:
Creates a middleware that checks whether any state was mutated in between dispatches or during a dispatch. If any mutations are detected, an error is thrown.
A utility function that allows defining a reducer as a mapping from action type to case reducer functions that handle these action types. The reducer's initial state is passed as the first argument.
Creates a selector creator function with the specified memoization function and options for customizing memoization behavior.
Creates a middleware that, after every state change, checks if the new state is serializable. If a non-serializable value is found within the state, an error is printed to the console.
Takes a snapshot of the current state of a draft and finalizes it (but without freezing). This is a great utility to print the current state during debugging (no Proxies in the way). The output of current can also be safely leaked outside the producer.
Spawns a saga
on an action dispatched to the Store that matches pattern
.
Saga will be called after it stops taking pattern
actions for ms
milliseconds. Purpose of this is to prevent calling saga until the actions
are settled off.
Returns an effect descriptor to block execution for ms
milliseconds and return val
value.
Creates an effect that instructs the middleware to flush all buffered items from the channel. Flushed items are returned back to the saga, so they can be utilized if needed.
Creates an Effect description that instructs the middleware to perform a
non-blocking call on fn
Forwards the action emitted from an event channel and pushes it to global state.
Freezes draftable objects. Returns the original object.
By default freezes shallowly, but if the second argument is true
it will freeze recursively.
Creates an effect that instructs the middleware to return a specific property of saga's context.
Returns true if value is an RTK-like action creator, with a static type property and match method.
A higher-order function that returns a function that may be used to check whether an action matches all of the supplied type guards or action creators.
A higher-order function that returns a function that may be used to check whether an action matches any one of the supplied type guards or action creators.
A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator.
Returns true if the given value is an Immer draft
Returns true if value is an action with a string type and valid Flux Standard Action keys.
A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator, and that the action is fulfilled.
The default isImmutable
function.
A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator, and that the action is pending.
Returns true if the passed value is "plain", i.e. a value that is either
directly JSON-serializable (boolean, number, string, array, plain object)
or undefined
.
A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator, and that the action is rejected.
A higher-order function that returns a function that may be used to check whether an action was created by an async thunk action creator, and that the action is rejected with value.
Creates an Effect description that instructs the middleware to wait for the result of a previously forked task.
Creates a Redux store that holds the state tree.
Creates a memoized version of a function with an optional
LRU (Least Recently Used) cache. The memoized function uses a cache to
store computed values. Depending on the maxSize
option, it will use
either a singleton cache (for a single entry) or an
LRU cache (for multiple entries).
Get the underlying object that is represented by the given draft
Creates an Effect description that instructs the middleware to dispatch an action to the Store. This effect is non-blocking, any errors that are thrown downstream (e.g. in a reducer) will bubble back into the saga.
Just like put
but the effect is blocking (if promise is returned from
dispatch
it will wait for its resolution) and will bubble up errors from
downstream.
Creates an Effect description that instructs the middleware to run a Race
between multiple Effects (this is similar to how
Promise.race([...])
behaves).
Creates an Effect description that instructs the middleware to call the
function fn
with args
as arguments. In case of failure will try to make
another call after delay
milliseconds, if a number of attempts < maxTries
.
Creates an effect that instructs the middleware to invoke the provided
selector on the current Store's state (i.e. returns the result of
selector(getState(), ...args)
).
Creates an effect that instructs the middleware to update its own context. This effect extends saga's context instead of replacing it.
Same as fork(fn, ...args)
but creates a detached task. A detached task
remains independent from its parent and acts like a top-level task. The
parent will not wait for detached tasks to terminate before returning and all
events which may affect the parent or the detached task are completely
independents (error, cancellation).
Creates an Effect description that instructs the middleware to wait for a
specified action on the Store. The Generator is suspended until an action
that matches pattern
is dispatched.
Spawns a saga
on each action dispatched to the Store that matches
pattern
.
Spawns a saga
on each action dispatched to the Store that matches
pattern
. And automatically cancels any previous saga
task started
previously if it's still running.
Spawns a saga
on each action dispatched to the Store that matches
pattern
. After spawning a task once, it blocks until spawned saga completes
and then starts to listen for a pattern
again.
Same as take(pattern)
but does not automatically terminate the Saga on an
END
action. Instead all Sagas blocked on a take Effect will get the END
object.
Spawns a saga
on an action dispatched to the Store that matches pattern
.
After spawning a task it's still accepting incoming actions into the
underlying buffer
, keeping at most 1 (the most recent one), but in the same
time holding up with spawning new task for ms
milliseconds (hence its name -
throttle
). Purpose of this is to ignore incoming actions for a given
period of time while processing a task.
Creates a tree of WeakMap
-based cache nodes based on the identity of the
arguments it's been called with (in this case, the extracted values from your input selectors).
This allows weakMapMemoize
to have an effectively infinite cache size.
Cache results will be kept in memory as long as references to the arguments still exist,
and then cleared out as the arguments are garbage-collected.
An action creator is, quite simply, a function that creates an action. Do not confuse the two terms—again, an action is a payload of information, and an action creator is a factory that creates an action.