Skip to content

Core Concepts

James, please edited this page Jun 10, 2017 · 5 revisions

There are three core concepts that are helpful to understand before working with redux-simple-resource.

Resources

A resource is an abstract object that you interact with in your application. For instance, if your web application manages a public library, then you might have two resources: "books" and "members." Resources typically have attributes, such as a "name" or "releaseYear."

For many web applications, resources are stored in an external system, and interactions with the resources occur over a network. These interactions are called "Requests."

Requests

Requests are asynchronous actions to change a resource. Often times, they are HTTP requests.

There are four operations you can perform against a resource using requests: you can create them, retrieve them, update them, or delete them. These four operations are collectively known as CRUD.

Because Requests often occur over a network, there is a notion of a "Request Status." This is the state that the request is in. All requests are in one of four states:

  • NULL: the request hasn't begun yet
  • PENDING: the request has started, but has not yet finished
  • FAILED: the operation did not complete
  • SUCCEEDED: the operation was successful

Resource Metadata

It was stated before that resources often have attributes associated with them, like "name" or "releaseYear." Resources can also have metadata associated with them.

Imagine that you have a particular book, and you're going through the process of deleting that book. It is useful to know when the delete request is in flight, and then if it fails or if it succeeds. This information is used to show loading indicators and messages to the user of your web application.

redux-simple-resource tracks this metadata for you as you make requests. This is the primary benefit that you get out of using redux-simple-resource: tracking this metadata for all resources across all requests requires a lot of boilerplate. With redux-simple-resource, you get all of this metadata tracking out of the box.

Clone this wiki locally