ioBroker.javascript
ioBroker.javascript copied to clipboard
Usage of cb-function does not work
I have some callback functions running. When restarting the script, those run until javascript-adapter is restarted. This behavior is also described here: https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md : If in the script some modules or functions are used with callbacks or cyclic calls, except setTimeout/setInterval, so they will be called again and again even if the new version of script exists or script is deleted.... To fix this feature restart the javascript adapter. You can use cb function to wrap you callback [...] to be sure, that no callback will be called if script is deleted or modified.
But unfortunately I cannot use the cb-function. cb-Function is underlined red when I type it in the TypeScript editor.
When compiling, this error is shown:
TypeScript compilation failed:[...] cb(function () { ^ ERROR: Cannot find name 'cb'.
Is there an alternative or was the cb-function renamed? Or is it just a bug?
@AlCalzone are there types missing?
Pretty sure. First time I've heard about this function
Can I add the type myself in my code or is this something only AlCalzone can fix in the adapter code?
Should be possible using
declare function cb(...): void;
(not sure about the arguments or the return type though, better double check that)