episoda 0.2.13 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/daemon/daemon-process.js +46 -1
- package/dist/daemon/daemon-process.js.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1827,6 +1827,32 @@ var require_websocket_client = __commonJS({
|
|
|
1827
1827
|
}
|
|
1828
1828
|
this.eventHandlers.get(event).push(handler);
|
|
1829
1829
|
}
|
|
1830
|
+
/**
|
|
1831
|
+
* EP812: Register a one-time event handler (removes itself after first call)
|
|
1832
|
+
* @param event - Event type
|
|
1833
|
+
* @param handler - Handler function
|
|
1834
|
+
*/
|
|
1835
|
+
once(event, handler) {
|
|
1836
|
+
const onceHandler = (message) => {
|
|
1837
|
+
this.off(event, onceHandler);
|
|
1838
|
+
handler(message);
|
|
1839
|
+
};
|
|
1840
|
+
this.on(event, onceHandler);
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* EP812: Remove an event handler
|
|
1844
|
+
* @param event - Event type
|
|
1845
|
+
* @param handler - Handler function to remove
|
|
1846
|
+
*/
|
|
1847
|
+
off(event, handler) {
|
|
1848
|
+
const handlers = this.eventHandlers.get(event);
|
|
1849
|
+
if (handlers) {
|
|
1850
|
+
const index = handlers.indexOf(handler);
|
|
1851
|
+
if (index !== -1) {
|
|
1852
|
+
handlers.splice(index, 1);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1830
1856
|
/**
|
|
1831
1857
|
* Send a message to the server
|
|
1832
1858
|
* @param message - Client message to send
|