I take that back. It is not possible to unset the listener for iap, iac or push. After talking to @Mathias_Westerdahl and @sicher we’ve instead decided to update the documentation for window.set_listener() and our new recommendation is to pass in an empty function if you no longer wish to get callbacks.
Oh, ok, so you’re setting the window.set_listener in a script inside a collection that gets unloaded? The error has no real effect. It only logs an error in the console. The code will continue to run despite this. It doesn’t look good in the log but it will have no effect. If you have all your engine callback setup in a main/controller script or module you would not run into this error.
I believe the idea is that these listeners are app-wide so that, in general, you never need to remove them, but instead manage it’s behaviour depending on the state of the app. But it may be that we need to add remove_listener() functions. Can you describe your use case in a bit more detail?
I think you’re right, and it is just a my misunderstanding.
About my case:
I have few collection. Some collection has own behavior on the window events, for example
game collection - show user the pause window when lost focus;
some collection - change position of particles when change window size (workaround, because I can’t use particle in gui((( );
all collection - turn off music when lost focus and turn on when gained focus (on some old devices music plays on lock screen).
Of course I can make one controller with many if-else for checking current collection and check behavior.
But better way for me have all behavior into collection, not in external controller.
My first solution: window.set_listener in every collection in init() and remove_listener in final(). And It doesn’t work because we cant remove listener.
But now I wrote small routing library for the events and all work as I need.