docs/docs/reference/admin-ui-api/services/notification-service.mdx
Provides toast notification functionality.
Example
class MyComponent {
constructor(private notificationService: NotificationService) {}
save() {
this.notificationService
.success(_('asset.notify-create-assets-success'), {
count: successCount,
});
}
}
```ts title="Signature"
class NotificationService {
constructor(i18nService: I18nService, resolver: ComponentFactoryResolver, overlayHostService: OverlayHostService)
success(message: string, translationVars?: { [key: string]: string | number }) => void;
info(message: string, translationVars?: { [key: string]: string | number }) => void;
warning(message: string, translationVars?: { [key: string]: string | number }) => void;
error(message: string, translationVars?: { [key: string]: string | number }) => void;
notify(config: ToastConfig) => void;
}
<MemberInfo kind="method" type={(message: string, translationVars?: { [key: string]: string | number }) => void} />
Display a success toast notification
<MemberInfo kind="method" type={(message: string, translationVars?: { [key: string]: string | number }) => void} />
Display an info toast notification
<MemberInfo kind="method" type={(message: string, translationVars?: { [key: string]: string | number }) => void} />
Display a warning toast notification
<MemberInfo kind="method" type={(message: string, translationVars?: { [key: string]: string | number }) => void} />
Display an error toast notification
<MemberInfo kind="method" type={(config: <a href='/reference/admin-ui-api/services/notification-service#toastconfig'>ToastConfig</a>) => void} />
Display a toast notification.
</div> ## NotificationType <GenerationInfo sourceFile="packages/admin-ui/src/lib/core/src/providers/notification/notification.service.ts" sourceLine="14" packageName="@vendure/admin-ui" />The types of notification available.
type NotificationType = 'info' | 'success' | 'error' | 'warning'
Configuration for a toast notification.
interface ToastConfig {
message: string;
translationVars?: { [key: string]: string | number };
type?: NotificationType;
duration?: number;
}
<MemberInfo kind="property" type={string} />
<MemberInfo kind="property" type={{ [key: string]: string | number }} />
<MemberInfo kind="property" type={<a href='/reference/admin-ui-api/services/notification-service#notificationtype'>NotificationType</a>} />
<MemberInfo kind="property" type={number} />