• 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("connecte­d",f);};
    
    wifi.on("connected",function(){print("co­nnected1");});
    wifi.on("connected",f);
    wifi.on("connected",function(){print("co­nnected3");});
    wifi.on("connected",function(){print("co­nnected4");});
    }
    
    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.

    Sof

About

Avatar for Polypod @Polypod started