-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _propTypes = require('prop-types'); | ||
|
||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
|
||
var _reactRedux = require('react-redux'); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var mapStateToProps = function mapStateToProps(_ref) { | ||
var loadingAll = _ref.loadingAll; | ||
return { loadingAll: loadingAll }; | ||
}; | ||
var Loading = function Loading(props) { | ||
return !Object.values(props.loadingAll).every(function (item) { | ||
return !item; | ||
}) ? props.children : false; | ||
}; | ||
|
||
Loading.propTypes = { | ||
children: _propTypes2.default.any | ||
}; | ||
|
||
exports.default = (0, _reactRedux.connect)(mapStateToProps)(Loading); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Loading = exports.loadingAll = exports.globalLoaderMiddleware = undefined; | ||
|
||
var _middleware = require('./middleware'); | ||
|
||
var _middleware2 = _interopRequireDefault(_middleware); | ||
|
||
var _reducer = require('./reducer'); | ||
|
||
var _reducer2 = _interopRequireDefault(_reducer); | ||
|
||
var _container = require('./container'); | ||
|
||
var _container2 = _interopRequireDefault(_container); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
exports.globalLoaderMiddleware = _middleware2.default; | ||
exports.loadingAll = _reducer2.default; | ||
exports.Loading = _container2.default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
exports.default = function (store) { | ||
var dispatch = store.dispatch; | ||
|
||
|
||
return function (next) { | ||
return function (action) { | ||
['_PENDING', '_FULFILLED', '_REJECTED'].forEach(function (item, key) { | ||
if (action.type.endsWith(item)) { | ||
dispatch({ | ||
type: '@@loadingAll/' + (!key ? 'STARTED' : 'FINISHED'), | ||
payload: action.type.replace(item, '') | ||
}); | ||
} | ||
}); | ||
|
||
next(action); | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
|
||
exports.default = function () { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
|
||
switch (action.type) { | ||
case '@@loadingAll/STARTED': | ||
return _extends({}, state, _defineProperty({}, action.payload, true)); | ||
|
||
case '@@loadingAll/FINISHED': | ||
return _extends({}, state, _defineProperty({}, action.payload, false)); | ||
|
||
default: | ||
return state; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters