metasection of a resource slice is structured similarly to the
resourcessection: it is an object, and each of its keys is a resource ID.
You can store additional information about individual resources within
meta. You can put anything that you would like here. Typically, the information that you store within
metaare the things that are useful for the client-side application, but that don't need to be sent to the server.
Resource metadata is intended to solve the problem some developers encounter when they pollute server-side data with client-side data. Mixing the two can get messy. Use metadata to keep things organized.
The following example slice has some metadata,
selected, associated with two resources. This value could represent that a user has "selected" these resources in the UI.
// ...there are other things on a resource slice, too. But this guide will
// focus on meta.
Out of the box, Redux Resource sets some metadata on your resources for you. This metadata represents whether or not that particular resource is being created, read, updated, or deleted using a network request. The four values are:
The value of each of these properties will be one of the four request statuses:
This metadata can be used to track the request status of CRUD operations against a particular resource in some situations. For more, refer to the Tracking Request Statuses guide.
There are two ways to modify metadata: synchronously and asynchronously. The guide on modifying resources describes both of these approaches.