Parcourir la source

docs: some more NanoEmitter clarification

Sv443 il y a 2 mois
Parent
commit
a42e14e1a9
1 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 4 4
      docs.md

+ 4 - 4
docs.md

@@ -1617,7 +1617,7 @@ interface MyEventMap {
 class MyClass extends NanoEmitter<MyEventMap> {
   constructor() {
     super({
-      // allow emitting events from outside the class:
+      // allow emitting events from outside the class body:
       publicEmit: true,
     });
 
@@ -1645,10 +1645,10 @@ myInstance.on("foo", (bar) => {
   console.log("foo event (outside):", bar);
 });
 
-// throws a TS error since `events` is protected:
+// throws a TS error since `events` is protected, but technically still works in JS:
 myInstance.events.emit("foo", "hello");
 
-// only works if publicEmit is set to true:
+// only works because publicEmit is set to true:
 myInstance.emit("baz", "hello from the outside");
 
 // remove all listeners:
@@ -1670,7 +1670,7 @@ interface MyEventMap {
 }
 
 const myEmitter = new NanoEmitter<MyEventMap>({
-  // allow emitting events from outside the class
+  // very important for functional usage - allow emitting events from outside the class body:
   publicEmit: true,
 });