-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setObject() function: callback not working as intended. #474
Comments
This is not completely correct ... The topic is that new Objects/States are registered by JavaScript Adapter when they are published in the system. This happens asynchronously after the setObject. I think it is no problem to already store the object data when the callitself was successull... |
I'm confused... What is correct now? |
Hi @Apollon77,
The given task is to set an object through |
You are all right and I wanted to do exactly the same ... I just described the reason for it and provided a potential solution. So, yes it is a bug :-) |
Many thanks @Apollon77. Now I do fully understand your previous response :-) |
I still do not understand, what is wrong |
@GermanBluefox setObject is only calling setForeignObject but is not registering the obejct in the internal "objects cache from javascript adapter". This "registration only happens once the objectChange event is coming in. Because of the async nature this will normally happen AFTER the callback of the setObject is called ... so when you want to access the object directly in the callback you might get an error because it is missing in the internal object cache |
Hi,
This issue is about the setObject() function:
setObject(id, obj, callback);
Per the documentation, we would expect that a certain function, which is provided to the callback parameter of "setObject()", is executed AFTER completion of setObject(). However, it seems that this is not working.
Please see ioBroker Forum Thread [Vorlage] Skript: Erstellen von User-Datenpunkten.
This forum post initially mentions an issue with setObject. If you scroll further down, you'll see more info on it.
Per my tests I have made, I can confirm that the callback is being executed like immediately, and not after setObject() function completion.
My environment: JavaScript adapter version: 4.3.4 // js-controller 2.2.7
Thanks guys! Let me know if you need any further info or tests.
The text was updated successfully, but these errors were encountered: