Skip to content

Commit d816847

Browse files
emmenkoacdlite
authored andcommitted
Add some JSDoc
1 parent 41f0bdf commit d816847

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/middleware/thunk.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* Given an action that returns a function, delegates its call
3+
* to the function itself by passing the control of the dispatching,
4+
* otherwise simply dispatch the action.
5+
* In other words, it allows to have async actions.
6+
*
7+
* @param {Function} getState - allow to access the current state
8+
* @return {Function} a new middleware
9+
*/
110
export default function thunkMiddleware(getState) {
211
return (next) => {
312
const recurse = (action) =>

src/utils/bindActionCreators.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import mapValues from '../utils/mapValues';
22

3+
/**
4+
* Given a list action creators, wrap them to the `dispatch` function
5+
* in order to be automatically dispatched when invoked.
6+
*
7+
* @param {Object} actionCreators - an object with the action functions
8+
* @param {Function} dispatch
9+
* @return {Object} the given object with wrapped actions
10+
*/
311
export default function bindActionCreators(actionCreators, dispatch) {
412
return mapValues(actionCreators, actionCreator =>
513
(...args) => dispatch(actionCreator(...args))

src/utils/getDisplayName.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Given a React component, return its name to be displayed.
3+
*
4+
* @param {React} Component
5+
* @return {String} the name of the component
6+
*/
17
export default function getDisplayName(Component) {
28
return Component.displayName || Component.name || 'Component';
39
}

0 commit comments

Comments
 (0)