added docusaurus admonitions to docs

This commit is contained in:
Shreedhar Hegde
2022-04-24 17:39:37 +05:30
parent eee780f110
commit 01114b42a4
25 changed files with 242 additions and 60 deletions
+5 -2
View File
@@ -77,9 +77,12 @@ class MyService extends NotificationService {
export default MyService;
```
:::note Note
> **Note:** a notification service must have a static property called `identifier` this is used to determine which classes are called when subscribing to different events. In this case the service identifier is `my-service` so to subscribe to notifications you must use:
> `notificationService.subscribe([eventname], "my-service")`
A notification service must have a static property called `identifier` this is used to determine which classes are called when subscribing to different events. In this case the service identifier is `my-service` so to subscribe to notifications you must use:
`notificationService.subscribe([eventname], "my-service")`
:::
The above class is an example implementation of a NotificationService. It uses a fictional email service called `CoolEmailSender` to send emails to a customer whenever an order is placed. The `sendNotification` implementation gets the event name and fetches relevant data based on what event is being processed; in this case it retrieves an order, which is later used when requesting `CoolEmailSender` to dispatch an email. The address to send the email to is likewise fetched from the order.