Even better docs

This commit is contained in:
Luke Barnard 2017-12-13 18:28:43 +00:00
parent 6b02f59fb7
commit 629cd13319
3 changed files with 22 additions and 15 deletions

View file

@ -19,12 +19,13 @@ import { asyncAction } from './actionCreators';
const GroupActions = {}; const GroupActions = {};
/** /**
* Create a GroupActions.fetchJoinedGroups action that represents an * Creates an action thunk that will do an asynchronous request to fetch
* asynchronous request to fetch the groups to which a user is joined. * the groups to which a user is joined.
* *
* @param {MatrixClient} matrixClient the matrix client to query. * @param {MatrixClient} matrixClient the matrix client to query.
* @returns {function} an asynchronous action of type * @returns {function} an action thunk that will dispatch actions
* GroupActions.fetchJoinedGroups. * indicating the status of the request.
* @see asyncAction
*/ */
GroupActions.fetchJoinedGroups = function(matrixClient) { GroupActions.fetchJoinedGroups = function(matrixClient) {
return asyncAction('GroupActions.fetchJoinedGroups', () => matrixClient.getJoinedGroups()); return asyncAction('GroupActions.fetchJoinedGroups', () => matrixClient.getJoinedGroups());

View file

@ -21,14 +21,15 @@ import TagOrderStore from '../stores/TagOrderStore';
const TagOrderActions = {}; const TagOrderActions = {};
/** /**
* Create a TagOrderActions.commitTagOrdering action that represents an * Creates an action thunk that will do an asynchronous request to
* asyncronous request to commit TagOrderStore.getOrderedTags() to account * commit TagOrderStore.getOrderedTags() to account data and dispatch
* data. * actions to indicate the status of the request.
* *
* @param {MatrixClient} matrixClient the matrix client to set the account * @param {MatrixClient} matrixClient the matrix client to set the
* data on. * account data on.
* @returns {function} an asynchronous action of type * @returns {function} an action thunk that will dispatch actions
* TagOrderActions.commitTagOrdering. * indicating the status of the request.
* @see asyncAction
*/ */
TagOrderActions.commitTagOrdering = function(matrixClient) { TagOrderActions.commitTagOrdering = function(matrixClient) {
return asyncAction('TagOrderActions.commitTagOrdering', () => { return asyncAction('TagOrderActions.commitTagOrdering', () => {

View file

@ -15,14 +15,19 @@ limitations under the License.
*/ */
/** /**
* Create an asynchronous action creator that will dispatch actions indicating * Create an action thunk that will dispatch actions indicating the current
* the current status of the promise returned by fn. * status of the Promise returned by fn.
*
* @param {string} id the id to give the dispatched actions. This is given a * @param {string} id the id to give the dispatched actions. This is given a
* suffix determining whether it is pending, successful or * suffix determining whether it is pending, successful or
* a failure. * a failure.
* @param {function} fn a function that returns a Promise. * @param {function} fn a function that returns a Promise.
* @returns {function} an asynchronous action creator - a function that uses * @returns {function} an action thunk - a function that uses its single
* its single argument as a dispatch function. * argument as a dispatch function to dispatch the
* following actions:
* `${id}.pending` and either
* `${id}.success` or
* `${id}.failure`.
*/ */
export function asyncAction(id, fn) { export function asyncAction(id, fn) {
return (dispatch) => { return (dispatch) => {