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 = {};
/**
* Create a GroupActions.fetchJoinedGroups action that represents an
* asynchronous request to fetch the groups to which a user is joined.
* Creates an action thunk that will do an asynchronous request to fetch
* the groups to which a user is joined.
*
* @param {MatrixClient} matrixClient the matrix client to query.
* @returns {function} an asynchronous action of type
* GroupActions.fetchJoinedGroups.
* @returns {function} an action thunk that will dispatch actions
* indicating the status of the request.
* @see asyncAction
*/
GroupActions.fetchJoinedGroups = function(matrixClient) {
return asyncAction('GroupActions.fetchJoinedGroups', () => matrixClient.getJoinedGroups());

View file

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

View file

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