From 325e1f9c4e75cce5ce39f5db71a19bcc5f921939 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 29 Apr 2020 15:10:23 +0100 Subject: [PATCH] Add jsdoc explaining ordering behaviour --- src/stores/ToastStore.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/stores/ToastStore.js b/src/stores/ToastStore.js index ad185e42db..8901736739 100644 --- a/src/stores/ToastStore.js +++ b/src/stores/ToastStore.js @@ -39,6 +39,15 @@ export default class ToastStore extends EventEmitter { this._toasts = []; } + /** + * Add or replace a toast + * If a toast with the same toastKey already exists, the given toast will replace it + * Toasts are always added underneath any toasts of the same priority, so existing + * toasts stay at the top unless a higher priority one arrives (better to not change the + * toast unless necessary). + * + * @param {boject} newToast The new toast + */ addOrReplaceToast(newToast) { if (newToast.priority === undefined) newToast.priority = ToastStore.PRIORITY_DEFAULT;