diff --git a/packages/notify/notify.ts b/packages/notify/notify.ts index 1c2bf9e4..97902821 100644 --- a/packages/notify/notify.ts +++ b/packages/notify/notify.ts @@ -31,6 +31,8 @@ const defaultOptions: NotifyOptions = { onClose: () => {}, }; +let currentOptions: NotifyOptions = { ...defaultOptions }; + function parseOptions( message?: NotifyOptions | string ): Partial { @@ -47,7 +49,7 @@ function getContext() { } export default function Notify(options: NotifyOptions | string) { - options = { ...defaultOptions, ...parseOptions(options) }; + options = { ...currentOptions, ...parseOptions(options) }; const context = options.context || getContext(); const notify = context.selectComponent(options.selector); @@ -74,3 +76,11 @@ Notify.clear = function (options?: NotifyOptions) { notify.hide(); } }; + +Notify.setDefaultOptions = (options: NotifyOptions) => { + Object.assign(currentOptions, options); +}; + +Notify.resetDefaultOptions = () => { + currentOptions = { ...defaultOptions }; +};