Skip to content

Commit cd3671b

Browse files
committed
# v0.1.5 process
1 parent 10824bd commit cd3671b

36 files changed

+561
-231
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ActionCreator + ActionSelector, reducers are created automatically
2222
[coverage-report](https://edtoken.github.io/redux-tide/coverage/lcov-report/index.html)
2323

2424

25-
[![Join the chat at https://gitter.im/practice-feature/redux-tide](https://badges.gitter.im/practice-feature/redux-tide.svg)](https://gitter.im/practice-feature/redux-tide?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
25+
[![Join the chat at https://gitter.im/practice-feature/redux-tide](https://badges.gitter.im/practice-feature/redux-tide.svg)](https://gitter.im/practice-feature/redux-tide?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2626

2727
[![npm version](https://badge.fury.io/js/redux-tide.svg)](https://badge.fury.io/js/redux-tide)
2828
[![Build Status](https://api.travis-ci.org/edtoken/redux-tide.svg?branch=master)](https://travis-ci.org/edtoken/redux-tide)
@@ -96,7 +96,7 @@ npm install redux-thunk --save
9696
------
9797
### Discussion
9898
You can connect to [Gitter chat room](https://gitter.im/practice-feature/redux-tide)
99-
[![Join the chat at https://gitter.im/practice-feature/redux-tide](https://badges.gitter.im/practice-feature/redux-tide.svg)](https://gitter.im/practice-feature/redux-tide?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
99+
[![Join the chat at https://gitter.im/practice-feature/redux-tide](https://badges.gitter.im/practice-feature/redux-tide.svg)](https://gitter.im/practice-feature/redux-tide?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
100100

101101
### Usage
102102
1. You might install library

lib/action.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -389,28 +389,31 @@ var makeAction = function makeAction(actionId, parentActionId, actionSchema, act
389389
};
390390
};
391391

392-
// /**
393-
// * Clean entity from entity reducer
394-
// *
395-
// * @memberOf action.makeAction.Action
396-
// * @type {Function}
397-
// *
398-
// * @example
399-
// * store.dispatch(userLoginAction.clean())
400-
// *
401-
// * @returns {Undefined} - returns None, only clear entity data
402-
// */
403-
// this.action.clean = () => {
404-
// return (dispatch, getState) => {
405-
// dispatch({
406-
// time: new Date().getTime(),
407-
// type: ACTION_CLEAN_TYPE_NAME,
408-
// prefix: ACTION_TYPE_PREFIX,
409-
// actionId: this.actionId,
410-
// actionSchema: this.schema
411-
// })
412-
// }
413-
// }
392+
/**
393+
* Delete entity from entity reducer
394+
*
395+
* @memberOf action.makeAction.Action
396+
* @type {Function}
397+
*
398+
* @example
399+
* store.dispatch(userDeleteAction.delete())
400+
*
401+
* @example
402+
* store.dispatch(userDeleteAction.withPrefix(userId).delete())
403+
*
404+
* @returns {Undefined} - returns None, only delete entity data
405+
*/
406+
this.action.delete = function () {
407+
return function (dispatch, getState) {
408+
dispatch({
409+
time: new Date().getTime(),
410+
type: _config.ACTION_DELETE_TYPE_NAME,
411+
prefix: _config.ACTION_TYPE_PREFIX,
412+
actionId: _this.actionId,
413+
actionSchema: _this.schema
414+
});
415+
};
416+
};
414417

415418
return this.action;
416419
};

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var ACTION_EMPTY_TYPE_NAME = exports.ACTION_EMPTY_TYPE_NAME = ACTION_TYPE_PREFIX
8383
* @const
8484
* @type {String}
8585
*/
86-
var ACTION_CLEAN_TYPE_NAME = exports.ACTION_CLEAN_TYPE_NAME = ACTION_TYPE_PREFIX + '-clean';
86+
var ACTION_DELETE_TYPE_NAME = exports.ACTION_DELETE_TYPE_NAME = ACTION_TYPE_PREFIX + '-clean';
8787

8888
/**
8989
* replaced default response mapper to callback

lib/reducer.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ var makeActionsReducer = function makeActionsReducer(defaultActionsState) {
6767
actionState = state.get(actionId);
6868
}
6969

70+
// delete entity id from actions
71+
if (action.type === _config.ACTION_DELETE_TYPE_NAME) {
72+
console.log('action delete', actionState);
73+
return state;
74+
}
75+
7076
actionState = actionState.merge({
7177
status: status,
7278
time: time,
@@ -121,6 +127,12 @@ var makeEntitiesReducer = function makeEntitiesReducer(defaultEntitiesState) {
121127

122128
var newEntitiesItems = normalizedPayloadSource ? normalizedPayloadSource.entities : {};
123129

130+
// delete entity id from actions
131+
if (action.type === _config.ACTION_DELETE_TYPE_NAME) {
132+
console.log('reducer delete');
133+
return state;
134+
}
135+
124136
// merge entity item data
125137
for (var entityName in newEntitiesItems) {
126138
for (var entityId in newEntitiesItems[entityName]) {

src/action.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*/
44

55
import {
6+
ACTION_DELETE_TYPE_NAME,
67
ACTION_EMPTY_TYPE_NAME,
7-
ACTION_CLEAN_TYPE_NAME,
88
ACTION_ID_KEY,
99
ACTION_IDS_KEY,
1010
ACTION_TYPE_PREFIX,
@@ -447,28 +447,31 @@ const makeAction = function(
447447
}
448448
}
449449

450-
// /**
451-
// * Clean entity from entity reducer
452-
// *
453-
// * @memberOf action.makeAction.Action
454-
// * @type {Function}
455-
// *
456-
// * @example
457-
// * store.dispatch(userLoginAction.clean())
458-
// *
459-
// * @returns {Undefined} - returns None, only clear entity data
460-
// */
461-
// this.action.clean = () => {
462-
// return (dispatch, getState) => {
463-
// dispatch({
464-
// time: new Date().getTime(),
465-
// type: ACTION_CLEAN_TYPE_NAME,
466-
// prefix: ACTION_TYPE_PREFIX,
467-
// actionId: this.actionId,
468-
// actionSchema: this.schema
469-
// })
470-
// }
471-
// }
450+
/**
451+
* Delete entity from entity reducer
452+
*
453+
* @memberOf action.makeAction.Action
454+
* @type {Function}
455+
*
456+
* @example
457+
* store.dispatch(userDeleteAction.delete())
458+
*
459+
* @example
460+
* store.dispatch(userDeleteAction.withPrefix(userId).delete())
461+
*
462+
* @returns {Undefined} - returns None, only delete entity data
463+
*/
464+
this.action.delete = () => {
465+
return (dispatch, getState) => {
466+
dispatch({
467+
time: new Date().getTime(),
468+
type: ACTION_DELETE_TYPE_NAME,
469+
prefix: ACTION_TYPE_PREFIX,
470+
actionId: this.actionId,
471+
actionSchema: this.schema
472+
})
473+
}
474+
}
472475

473476
return this.action
474477
}

src/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const ACTION_EMPTY_TYPE_NAME = `${ACTION_TYPE_PREFIX}-empty`
7878
* @const
7979
* @type {String}
8080
*/
81-
export const ACTION_CLEAN_TYPE_NAME = `${ACTION_TYPE_PREFIX}-clean`
81+
export const ACTION_DELETE_TYPE_NAME = `${ACTION_TYPE_PREFIX}-clean`
8282

8383
/**
8484
* replaced default response mapper to callback

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { createReducers } from './reducer'
33
import {
44
denomalizeEntityItemById,
55
getActionData,
6-
getMergedActionsData,
76
getEntityItemsByAction,
87
getEntityItemsByEntityName,
98
getEntityItemsBySchema,
10-
getEntityReducer
9+
getEntityReducer,
10+
getMergedActionsData
1111
} from './selector'
1212

1313
import {

src/reducer.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { fromJS } from 'immutable'
66
import { normalize } from 'normalizr'
77

88
import {
9+
ACTION_DELETE_TYPE_NAME,
910
ACTION_EMPTY_TYPE_NAME,
1011
ACTION_TYPE_PREFIX,
1112
ACTIONS_REDUCER_NAME,
@@ -67,6 +68,12 @@ const makeActionsReducer = defaultActionsState => {
6768
actionState = state.get(actionId)
6869
}
6970

71+
// delete entity id from actions
72+
if (action.type === ACTION_DELETE_TYPE_NAME) {
73+
console.log('action delete', actionState)
74+
return state
75+
}
76+
7077
actionState = actionState.merge({
7178
status,
7279
time,
@@ -136,6 +143,12 @@ const makeEntitiesReducer = defaultEntitiesState => {
136143
? normalizedPayloadSource.entities
137144
: {}
138145

146+
// delete entity id from actions
147+
if (action.type === ACTION_DELETE_TYPE_NAME) {
148+
console.log('reducer delete')
149+
return state
150+
}
151+
139152
// merge entity item data
140153
for (let entityName in newEntitiesItems) {
141154
for (let entityId in newEntitiesItems[entityName]) {

test/action.spec.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import 'should'
22
import sinon from 'sinon'
33
import { schema } from 'normalizr'
4-
5-
require('should-sinon')
6-
74
import {
5+
createAction,
86
makeActionHandler,
9-
makeActionUniqId,
10-
makeAction,
11-
createAction
7+
makeActionUniqId
128
} from '../src/action'
139

10+
require('should-sinon')
11+
1412
describe('action makeActionUniqId ', function() {
1513
it('makeActionUniqId returns uniquie ids', function() {
1614
const result = new Set([

test/config.spec.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import 'should'
22
import sinon from 'sinon'
33
import { schema } from 'normalizr'
4-
5-
require('should-sinon')
6-
74
import {
8-
IS_TEST_ENVIRONMENT,
9-
STATUSES,
5+
ACTION_EMPTY_TYPE_NAME,
106
ACTION_ID_KEY,
117
ACTION_IDS_KEY,
128
ACTION_TYPE_PREFIX,
139
ACTIONS_REDUCER_NAME,
1410
ENTITIES_REDUCER_NAME,
15-
ACTION_EMPTY_TYPE_NAME,
11+
IS_TEST_ENVIRONMENT,
1612
setDefaultResponseMapper,
17-
setDenormalize
13+
setDenormalize,
14+
STATUSES
1815
} from '../src/config'
1916

2017
import { createAction } from '../src/action'
2118

19+
require('should-sinon')
20+
2221
describe('config is valid', function() {
2322
it('should define all required variables', function() {
2423
IS_TEST_ENVIRONMENT.should.not.be.undefined()

0 commit comments

Comments
 (0)