Hi,
I am so happy since I found esp and espruino, but I have a little problem. I have a small code with several listeners waiting wifi connection on boot and removing themselves afterward. It appears that the first to call wifi.removeListener remove not only this listener but also the following ones. Try for yourself :
function start (){
var wifi=require("Wifi");
var f=function(){
print("connected2 " );
require("Wifi").removeListener("connected",f);};
wifi.on("connected",function(){print("connected1");});
wifi.on("connected",f);
wifi.on("connected",function(){print("connected3");});
wifi.on("connected",function(){print("connected4");});
}
E.on("init",start);
save();
Result is :
connected1
connected2
I expected connected3 and connected4, but they never get displayed. But if I remove the wifi.removeListener(), they are displayed. I am removing listeners mostly in order to save memory.
Am I am misunderstanding the situation ? is wifi.removeListener() working properly ?Please help.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
I am so happy since I found esp and espruino, but I have a little problem. I have a small code with several listeners waiting wifi connection on boot and removing themselves afterward. It appears that the first to call wifi.removeListener remove not only this listener but also the following ones. Try for yourself :
Result is :
I expected connected3 and connected4, but they never get displayed. But if I remove the wifi.removeListener(), they are displayed. I am removing listeners mostly in order to save memory.
Am I am misunderstanding the situation ? is wifi.removeListener() working properly ?Please help.
Sof