0
Не ошибка
maximum number of event listeners?
r riksma 9 лет назад
в iRidium Script / Interface scripts
•
обновлен Ekaterina (head of support) 9 лет назад •
12
while adding a new feature to my project i ran into the following error message:
07-28-2015 12:10:31 Kernel.Info 192.168.253.102 [28-07-2015 12:10:31.000] WARNING Script exception: RangeError: /var/mobile/Containers/Data/Application/52D7C331-9EEE-43AB-9979-20E9A2C44C3D/Library/Caches/iRidiumMobile/project/Isyglt.js:96: error
The line defines an listener like this:
IR.AddListener(IR.EVENT_RECEIVE_TEXT,driver,function(text){});
if i try to create a listener elsewhere in the project some other listener that has worked fine before will give this error.
if i remove a random listener the error disappears.
It seems to me there is a maximum number of event listeners and i have reached this maximum.
Is this true, and is there any way to fix this?
07-28-2015 12:10:31 Kernel.Info 192.168.253.102 [28-07-2015 12:10:31.000] WARNING Script exception: RangeError: /var/mobile/Containers/Data/Application/52D7C331-9EEE-43AB-9979-20E9A2C44C3D/Library/Caches/iRidiumMobile/project/Isyglt.js:96: error
The line defines an listener like this:
IR.AddListener(IR.EVENT_RECEIVE_TEXT,driver,function(text){});
if i try to create a listener elsewhere in the project some other listener that has worked fine before will give this error.
if i remove a random listener the error disappears.
It seems to me there is a maximum number of event listeners and i have reached this maximum.
Is this true, and is there any way to fix this?
Сервис поддержки клиентов работает на платформе UserEcho
Could you try and work out something in a future version to make sure we don't run into problems with this?
I can imagine there will be much larger projects than the one i'm working on.
These are my suggestions:
2. you can add the counter of created listeners, like listener++ in each function started by listener. It is not a problem
3. You can do it with You have to optimize you scripts using prototypes and deleting of unused listeners
I thought removing listeners and pages wasn't possible yet, but if it is the limit of 1024 should be more than enough.
Thank you!
I tested this with the following code but i would like to know for sure i'm not accidentally leaving stuff in memory:
function press (){IR.Log("abc");}
for( var i = 0; i > 5000; i++){
IR.GetItem("Page 1").CreateItem(IR.ITEM_BUTTON,'Button',10,10,200,100);
IR.AddListener(IR.EVENT_ITEM_PRESS, IR.GetItem("Page 1").GetItem('Button'), press);
IR.DeleteItem(IR.GetItem("Page 1").GetItem('Button'));
}
IR.GetItem("Page 1").CreateItem(IR.ITEM_BUTTON,'Button',10,10,200,100);
IR.AddListener(IR.EVENT_ITEM_PRESS, IR.GetItem("Page 1").GetItem('Button'), press);
Listeners did not removed after delete the item, you need to remove listeners before deleting the item
is there any way to remove all listeners from an item or can i remove a listener by referencing it from a variable?
The only way i currently know how to remove a listener is not really straightforward because i will have to add a RemoveListener line every time i use AddListener so it's easy to make mistakes.
I have hit this limit with a large project where I need to change states based on project tokens as there is no feedbac.
The project is due to be handed over tomorrow.... aaagggghhhhh!!!!!
I have reduced as much as I can but there is a listener on each button, slider and edit and colour picker, and no way around this.
Suggestions anyone??? Please
Please create the listeners only on visible pages and remove them when hide the page