Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Added API signature
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Jan 10, 2017
1 parent 54b6227 commit 0e6c3b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {InvalidConfigError} from './errors';
import {API_SIGNATURE} from './types';

/**
* Create an API endpoint action. (Internal function)
Expand All @@ -15,6 +16,7 @@ import {InvalidConfigError} from './errors';
*/
export const _createApiAction = (apiName, isEntity, entityName, endpointName, types) => {
return (payload) => ({
signature: API_SIGNATURE,
api: apiName,
type: types.request,
isEntity,
Expand Down
3 changes: 3 additions & 0 deletions src/middleware.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {InvalidConfigError, RequestError} from './errors';
import {_makeApiRequest} from './request';
import {API_SIGNATURE} from './types';

/**
* Create Redux middleware for one or more API's
Expand Down Expand Up @@ -49,6 +50,8 @@ export const createApiMiddleware = (...apis) => {

// Generate dispatch action function (improves readability of the code below)
const dispatchAction = ({type, isError = false, error = null, payload = null, hasPayloadError = false, payloadError = null}) => next({
signature: API_SIGNATURE,
api: apiName,
type,
isEntity,
entity: entityName,
Expand Down
8 changes: 8 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import {decamelize} from 'humps';

import {InvalidConfigError} from './errors';

/**
* API signature to quickly identify our actions
*/
export const API_SIGNATURE = Symbol('REDUX_CACHED_API');

/**
* Request stages
*/
export const requestStages = {
request: 'REQUEST',
success: 'SUCCESS',
Expand Down

0 comments on commit 0e6c3b9

Please sign in to comment.