MDL-72108 js: Fix incorrect jsdoc examples for core/ajax

This commit is contained in:
Andrew Nicols 2021-07-08 10:33:31 +08:00
parent 3610f1ee3b
commit 36f21508fb
2 changed files with 25 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@ -150,29 +150,45 @@ define(['jquery', 'core/config', 'core/log', 'core/url'], function($, config, Lo
* @return {Promise[]} The Promises for each of the supplied requests.
* The order of the Promise matches the order of requests exactly.
*
* @example <caption>A simple example that you might find in a repository module</caption>
*
* import {call as fetchMany} from 'core/ajax';
*
* export const fetchMessages = timeSince => fetchMany([{methodname: 'core_message_get_messages', args: {timeSince}}])[0];
*
* export const fetchNotifications = timeSince => fetchMany([{
* methodname: 'core_message_get_notifications',
* args: {
* timeSince,
* }
* }])[0];
*
* export const fetchSomethingElse = (some, params, here) => fetchMany([{
* methodname: 'core_get_something_else',
* args: {
* some,
* params,
* gohere: here,
* },
* }])[0];
*
* @example <caption>An example of fetching a string using the cachekey parameter</caption>
* import {call as fetchMany} from 'core/ajax';
* import * as Notification from 'core/notification';
*
* export const performAction = (some, args) => {
* Promises.all(fetchMany('core_get_string', {
* Promises.all(fetchMany([{methodname: 'core_get_string', args: {
* stringid: 'do_not_copy',
* component: 'core',
* lang: 'en',
* stringparams: [],
* }, true, false, false, undefined, M.cfg.langrev))
* }}], true, false, false, undefined, M.cfg.langrev))
* .then(([doNotCopyString]) => {
* window.console.log(doNotCopyString);
* })
* .catch(Notification.exception);
* };
*
* @example <caption>A simple example that you might find in a repository function</caption>
*
* import {call as fetchMany} from 'core/ajax';
*
* export const fetchMessages = timeSince => fetchMany('core_message_get_messages', {timeSince}})[0];
* export const fetchNotifications = timeSince => fetchMany('core_message_get_notifications', {timeSince}})[0];
*/
call: function(requests, async, loginrequired, nosessionupdate, timeout, cachekey) {
$(window).bind('beforeunload', function() {