Skip to content

Commit

Permalink
# v0.1.5 process
Browse files Browse the repository at this point in the history
  • Loading branch information
edtoken committed Jan 24, 2018
1 parent 10824bd commit cd3671b
Show file tree
Hide file tree
Showing 36 changed files with 561 additions and 231 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ActionCreator + ActionSelector, reducers are created automatically
[coverage-report](https://edtoken.github.io/redux-tide/coverage/lcov-report/index.html)


[![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)
[![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)

[![npm version](https://badge.fury.io/js/redux-tide.svg)](https://badge.fury.io/js/redux-tide)
[![Build Status](https://api.travis-ci.org/edtoken/redux-tide.svg?branch=master)](https://travis-ci.org/edtoken/redux-tide)
Expand Down Expand Up @@ -96,7 +96,7 @@ npm install redux-thunk --save
------
### Discussion
You can connect to [Gitter chat room](https://gitter.im/practice-feature/redux-tide)
[![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)
[![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)

### Usage
1. You might install library
Expand Down
47 changes: 25 additions & 22 deletions lib/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,28 +389,31 @@ var makeAction = function makeAction(actionId, parentActionId, actionSchema, act
};
};

// /**
// * Clean entity from entity reducer
// *
// * @memberOf action.makeAction.Action
// * @type {Function}
// *
// * @example
// * store.dispatch(userLoginAction.clean())
// *
// * @returns {Undefined} - returns None, only clear entity data
// */
// this.action.clean = () => {
// return (dispatch, getState) => {
// dispatch({
// time: new Date().getTime(),
// type: ACTION_CLEAN_TYPE_NAME,
// prefix: ACTION_TYPE_PREFIX,
// actionId: this.actionId,
// actionSchema: this.schema
// })
// }
// }
/**
* Delete entity from entity reducer
*
* @memberOf action.makeAction.Action
* @type {Function}
*
* @example
* store.dispatch(userDeleteAction.delete())
*
* @example
* store.dispatch(userDeleteAction.withPrefix(userId).delete())
*
* @returns {Undefined} - returns None, only delete entity data
*/
this.action.delete = function () {
return function (dispatch, getState) {
dispatch({
time: new Date().getTime(),
type: _config.ACTION_DELETE_TYPE_NAME,
prefix: _config.ACTION_TYPE_PREFIX,
actionId: _this.actionId,
actionSchema: _this.schema
});
};
};

return this.action;
};
Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var ACTION_EMPTY_TYPE_NAME = exports.ACTION_EMPTY_TYPE_NAME = ACTION_TYPE_PREFIX
* @const
* @type {String}
*/
var ACTION_CLEAN_TYPE_NAME = exports.ACTION_CLEAN_TYPE_NAME = ACTION_TYPE_PREFIX + '-clean';
var ACTION_DELETE_TYPE_NAME = exports.ACTION_DELETE_TYPE_NAME = ACTION_TYPE_PREFIX + '-clean';

/**
* replaced default response mapper to callback
Expand Down
12 changes: 12 additions & 0 deletions lib/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ var makeActionsReducer = function makeActionsReducer(defaultActionsState) {
actionState = state.get(actionId);
}

// delete entity id from actions
if (action.type === _config.ACTION_DELETE_TYPE_NAME) {
console.log('action delete', actionState);
return state;
}

actionState = actionState.merge({
status: status,
time: time,
Expand Down Expand Up @@ -121,6 +127,12 @@ var makeEntitiesReducer = function makeEntitiesReducer(defaultEntitiesState) {

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

// delete entity id from actions
if (action.type === _config.ACTION_DELETE_TYPE_NAME) {
console.log('reducer delete');
return state;
}

// merge entity item data
for (var entityName in newEntitiesItems) {
for (var entityId in newEntitiesItems[entityName]) {
Expand Down
49 changes: 26 additions & 23 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/

import {
ACTION_DELETE_TYPE_NAME,
ACTION_EMPTY_TYPE_NAME,
ACTION_CLEAN_TYPE_NAME,
ACTION_ID_KEY,
ACTION_IDS_KEY,
ACTION_TYPE_PREFIX,
Expand Down Expand Up @@ -447,28 +447,31 @@ const makeAction = function(
}
}

// /**
// * Clean entity from entity reducer
// *
// * @memberOf action.makeAction.Action
// * @type {Function}
// *
// * @example
// * store.dispatch(userLoginAction.clean())
// *
// * @returns {Undefined} - returns None, only clear entity data
// */
// this.action.clean = () => {
// return (dispatch, getState) => {
// dispatch({
// time: new Date().getTime(),
// type: ACTION_CLEAN_TYPE_NAME,
// prefix: ACTION_TYPE_PREFIX,
// actionId: this.actionId,
// actionSchema: this.schema
// })
// }
// }
/**
* Delete entity from entity reducer
*
* @memberOf action.makeAction.Action
* @type {Function}
*
* @example
* store.dispatch(userDeleteAction.delete())
*
* @example
* store.dispatch(userDeleteAction.withPrefix(userId).delete())
*
* @returns {Undefined} - returns None, only delete entity data
*/
this.action.delete = () => {
return (dispatch, getState) => {
dispatch({
time: new Date().getTime(),
type: ACTION_DELETE_TYPE_NAME,
prefix: ACTION_TYPE_PREFIX,
actionId: this.actionId,
actionSchema: this.schema
})
}
}

return this.action
}
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const ACTION_EMPTY_TYPE_NAME = `${ACTION_TYPE_PREFIX}-empty`
* @const
* @type {String}
*/
export const ACTION_CLEAN_TYPE_NAME = `${ACTION_TYPE_PREFIX}-clean`
export const ACTION_DELETE_TYPE_NAME = `${ACTION_TYPE_PREFIX}-clean`

/**
* replaced default response mapper to callback
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { createReducers } from './reducer'
import {
denomalizeEntityItemById,
getActionData,
getMergedActionsData,
getEntityItemsByAction,
getEntityItemsByEntityName,
getEntityItemsBySchema,
getEntityReducer
getEntityReducer,
getMergedActionsData
} from './selector'

import {
Expand Down
13 changes: 13 additions & 0 deletions src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { fromJS } from 'immutable'
import { normalize } from 'normalizr'

import {
ACTION_DELETE_TYPE_NAME,
ACTION_EMPTY_TYPE_NAME,
ACTION_TYPE_PREFIX,
ACTIONS_REDUCER_NAME,
Expand Down Expand Up @@ -67,6 +68,12 @@ const makeActionsReducer = defaultActionsState => {
actionState = state.get(actionId)
}

// delete entity id from actions
if (action.type === ACTION_DELETE_TYPE_NAME) {
console.log('action delete', actionState)
return state
}

actionState = actionState.merge({
status,
time,
Expand Down Expand Up @@ -136,6 +143,12 @@ const makeEntitiesReducer = defaultEntitiesState => {
? normalizedPayloadSource.entities
: {}

// delete entity id from actions
if (action.type === ACTION_DELETE_TYPE_NAME) {
console.log('reducer delete')
return state
}

// merge entity item data
for (let entityName in newEntitiesItems) {
for (let entityId in newEntitiesItems[entityName]) {
Expand Down
10 changes: 4 additions & 6 deletions test/action.spec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import 'should'
import sinon from 'sinon'
import { schema } from 'normalizr'

require('should-sinon')

import {
createAction,
makeActionHandler,
makeActionUniqId,
makeAction,
createAction
makeActionUniqId
} from '../src/action'

require('should-sinon')

describe('action makeActionUniqId ', function() {
it('makeActionUniqId returns uniquie ids', function() {
const result = new Set([
Expand Down
13 changes: 6 additions & 7 deletions test/config.spec.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import 'should'
import sinon from 'sinon'
import { schema } from 'normalizr'

require('should-sinon')

import {
IS_TEST_ENVIRONMENT,
STATUSES,
ACTION_EMPTY_TYPE_NAME,
ACTION_ID_KEY,
ACTION_IDS_KEY,
ACTION_TYPE_PREFIX,
ACTIONS_REDUCER_NAME,
ENTITIES_REDUCER_NAME,
ACTION_EMPTY_TYPE_NAME,
IS_TEST_ENVIRONMENT,
setDefaultResponseMapper,
setDenormalize
setDenormalize,
STATUSES
} from '../src/config'

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

require('should-sinon')

describe('config is valid', function() {
it('should define all required variables', function() {
IS_TEST_ENVIRONMENT.should.not.be.undefined()
Expand Down
2 changes: 1 addition & 1 deletion test/helper.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { uniqPrefix, parseError } from '../src/helper'
import { parseError, uniqPrefix } from '../src/helper'

describe('helper uniqPrefix', function() {
it('created uniq prefixed', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/selector.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'should'
import { schema } from 'normalizr'
import { fromJS } from 'immutable'

import { ENTITIES_REDUCER_NAME, ACTIONS_REDUCER_NAME } from '../src/config'
import { ACTIONS_REDUCER_NAME, ENTITIES_REDUCER_NAME } from '../src/config'
import {
getActionData,
getEntityItemsByAction,
Expand Down
60 changes: 32 additions & 28 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,13 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"autoprefixer": "7.1.6",
"babel-core": "6.26.0",
"babel-eslint": "7.2.3",
"babel-jest": "20.0.3",
"babel-loader": "7.1.2",
"babel-preset-react-app": "^3.1.0",
"babel-runtime": "6.26.0",
"axios": "^0.17.1",
"redux-tide": "^0.1.4",
"case-sensitive-paths-webpack-plugin": "2.1.1",
"chalk": "1.1.3",
"css-loader": "0.28.7",
"dotenv": "4.0.0",
"eslint": "4.10.0",
"eslint-config-react-app": "^2.0.1",
"eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.4.0",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"fs-extra": "3.0.1",
"history": "^4.7.2",
"html-loader": "^0.5.4",
"html-webpack-plugin": "2.29.0",
"jest": "20.0.4",
"markdown-loader": "^2.0.2",
"normalizr": "^3.2.4",
"object-assign": "4.1.1",
"postcss-flexbugs-fixes": "3.2.0",
Expand All @@ -46,20 +27,43 @@
"redux-devtools-dock-monitor": "^1.1.3",
"redux-devtools-log-monitor": "^1.4.0",
"redux-thunk": "^2.2.0",
"style-loader": "0.19.0",
"sw-precache-webpack-plugin": "0.11.4",
"url-loader": "0.6.2",
"webpack": "3.8.1",
"webpack-dev-server": "2.9.4",
"webpack-manifest-plugin": "1.3.2",
"whatwg-fetch": "2.0.3"
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom"
},
"devDependencies": {},
"devDependencies": {
"codesandbox": "^1.1.14",
"autoprefixer": "7.1.6",
"babel-core": "6.26.0",
"babel-eslint": "7.2.3",
"babel-jest": "20.0.3",
"babel-loader": "7.1.2",
"babel-preset-react-app": "^3.1.0",
"babel-runtime": "6.26.0",
"eslint": "4.10.0",
"eslint-config-react-app": "^2.0.1",
"eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.4.0",
"style-loader": "0.19.0",
"sw-precache-webpack-plugin": "0.11.4",
"url-loader": "0.6.2",
"webpack": "3.8.1",
"webpack-dev-server": "2.9.4",
"webpack-manifest-plugin": "1.3.2",
"css-loader": "0.28.7",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"html-loader": "^0.5.4",
"html-webpack-plugin": "2.29.0",
"markdown-loader": "^2.0.2",
"jest": "20.0.4"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,mjs}"
Expand Down
Loading

0 comments on commit cd3671b

Please sign in to comment.