MDL-73314 core: Accept a Promise which resolves to string for toasts
This commit is contained in:
File diff suppressed because one or more lines are too long
+12
-11
@@ -47,7 +47,7 @@ export const addToastRegion = async(parent) => {
|
||||
* Add a new toast or snackbar notification to the page.
|
||||
*
|
||||
* @method
|
||||
* @param {String} message
|
||||
* @param {String|Promise<string>} message
|
||||
* @param {Object} configuration
|
||||
* @param {String} [configuration.title]
|
||||
* @param {String} [configuration.subtitle]
|
||||
@@ -60,16 +60,17 @@ export const addToastRegion = async(parent) => {
|
||||
* import {add as addToast} from 'core/toast';
|
||||
* import {get_string as getString} from 'core/str';
|
||||
*
|
||||
* getString('example', 'mod_myexample')
|
||||
* .then(str => {
|
||||
* addToast(str, {
|
||||
* type: 'warning',
|
||||
* autohide: false,
|
||||
* closeButton: true,
|
||||
* });
|
||||
* return;
|
||||
* })
|
||||
* .catch();
|
||||
* addToast('Example string', {
|
||||
* type: 'warning',
|
||||
* autohide: false,
|
||||
* closeButton: true,
|
||||
* });
|
||||
*
|
||||
* addToast(getString('example', 'mod_myexample'), {
|
||||
* type: 'warning',
|
||||
* autohide: false,
|
||||
* closeButton: true,
|
||||
* });
|
||||
*/
|
||||
export const add = async(message, configuration) => {
|
||||
const pendingPromise = new Pending('addToastRegion');
|
||||
|
||||
Reference in New Issue
Block a user