Skip to content

Commit 0ff16e8

Browse files
committed
1.19: Add this.removeAllListeners
1 parent dfe69f4 commit 0ff16e8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

uart.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ UART.getConnection().espruinoEval("1+2").then(res => console.log("=",res));
9191
ChangeLog:
9292
9393
...
94+
1.19: Add this.removeAllListeners
9495
1.18: Add connection.on("line"...) event, export parseRJSON, handle 'NaN' in RJSON
9596
1.17: Work around Linux Web Bluetooth Bug (connect-disconnect-connect to same device)
9697
1.16: Misc reliability improvements (if connection fails during write or if BLE Characteristics reused)
@@ -405,6 +406,7 @@ To do:
405406
on(evt,cb) { let e = "on"+evt; if (!this[e]) this[e]=[]; this[e].push(cb); } // on only works with a single handler
406407
emit(evt,data1,data2) { let e = "on"+evt; if (this[e]) this[e].forEach(fn=>fn(data1,data2)); }
407408
removeListener(evt,callback) { let e = "on"+evt; if (this[e]) this[e]=this[e].filter(fn=>fn!=callback); }
409+
removeAllListeners(evt) { let e = "on"+evt; delete this[e]; }
408410
// on("open", () => ... ) connection opened
409411
// on("close", () => ... ) connection closed
410412
// on("data", (data) => ... ) when data is received (as string)
@@ -1286,7 +1288,7 @@ To do:
12861288
// ----------------------------------------------------------
12871289

12881290
var uart = {
1289-
version : "1.18",
1291+
version : "1.19",
12901292
/// Are we writing debug information? 0 is no, 1 is some, 2 is more, 3 is all.
12911293
debug : 1,
12921294
/// Should we use flow control? Default is true
@@ -1317,7 +1319,7 @@ To do:
13171319
connect(options).then(callback, err => callback(null,err));
13181320
return connection;
13191321
},
1320-
/// Write to a device and callback when the data is written (returns promise, or can take callback). Creates a connection if it doesn't exist
1322+
/// Write to a device and callback when the data is written (returns promise, or can take callback). Creates a connection if it doesn't exist. NOTE: If the device is constantly sending and we're not waiting for a newline, this can take up to UART.timeoutMax to return
13211323
write : write, // write(string, callback, callbackForNewline) -> Promise
13221324
/// Evaluate an expression and call cb with the result (returns promise, or can take callback). Creates a connection if it doesn't exist
13231325
eval : evaluate, // eval(expr_as_string, callback) -> Promise

0 commit comments

Comments
 (0)