Skip to content

Commit

Permalink
MDL-73314 core: Accept a Promise which resolves to string for toasts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 24, 2022
1 parent e63604f commit ce0ac9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/amd/build/toast.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions lib/amd/src/toast.js
Expand Up @@ -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]
Expand All @@ -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');
Expand Down

0 comments on commit ce0ac9c

Please sign in to comment.