@commercetools-frontend/actions-global
Version:
Global redux actions for a MC application
42 lines (41 loc) • 1.52 kB
TypeScript
import type { TNotificationMetaOptions, TAddNotificationAction, TNotification } from '@commercetools-frontend/notifications';
import type { TShowNotification } from '../types';
type TNotificationHook<Notification extends TShowNotification> = (content: Notification, meta?: TNotificationMetaOptions) => TAddNotificationAction<Notification & TNotification>;
/**
* Dispatch a notification.
*
* @example
* const showSuccessNotification = useShowNotification();
* showSuccessNotification({
* domain: NOTIFICATION_DOMAINS.SIDE,
* kind: NOTIFICATION_KINDS_SIDE.success,
* text: "All good!",
* });
*/
declare function useShowNotification<Notification extends TShowNotification>(): TNotificationHook<Notification>;
/**
* Dispatch a notification.
*
* @deprecated: Avoid passing the notification options here.
* Instead define them in the notification function itself.
*
* @example
* Bad:
* const showSuccessNotification = useShowNotification({
* domain: NOTIFICATION_DOMAINS.SIDE,
* kind: NOTIFICATION_KINDS_SIDE.success,
* });
* showSuccessNotification({
* text: "All good!",
* });
*
* Good:
* const showSuccessNotification = useShowNotification();
* showSuccessNotification({
* domain: NOTIFICATION_DOMAINS.SIDE,
* kind: NOTIFICATION_KINDS_SIDE.success,
* text: "All good!",
* });
*/
declare function useShowNotification<Notification extends TShowNotification>(notificationFragment: Partial<Notification>): TNotificationHook<Notification>;
export default useShowNotification;