@@ -54,12 +54,12 @@ export type EventNotifier<T, E = Error> = {
54
54
* @example
55
55
*
56
56
* ```ts
57
- * const notifier = createEventNotifier<{ type: string; data: unknown }>();
57
+ * const notifier = createEventNotifier<{ type: string; value: number }>();
58
58
* notifier.onEvent((event) => {
59
- * console.log(`Received ${event.type} with data :`, event.data );
59
+ * console.log(`Received ${event.type} with value :`, event.value );
60
60
* });
61
61
*
62
- * notifier.notify({ type: 'update ', data: { id: 123, status: 'complete' } });
62
+ * notifier.notify({ type: 'progress ', value: 75 });
63
63
* ```
64
64
*
65
65
* @param event The event to send to all listeners or a function that returns such event.
@@ -91,12 +91,15 @@ export type EventNotifier<T, E = Error> = {
91
91
* const stringNotifier = createEventNotifier<string>();
92
92
*
93
93
* // Complex object event notifier
94
- * interface UserEvent {
95
- * type: 'created' | 'updated' | 'deleted';
96
- * userId: number;
97
- * data?: Record<string, unknown>;
94
+ * interface TaskEvent {
95
+ * type: 'started' | 'completed' | 'failed';
96
+ * taskId: number;
97
+ * details: {
98
+ * name: string;
99
+ * duration?: number;
100
+ * };
98
101
* }
99
- * const userNotifier = createEventNotifier<UserEvent >();
102
+ * const taskNotifier = createEventNotifier<TaskEvent >();
100
103
* ```
101
104
*
102
105
* @template T The type of events this notifier will handle
0 commit comments