Skip to content

Commit 9b4ee48

Browse files
authored
[jsscripting] Upgrade openhab-js to 5.8.1 (openhab#17885)
Changelog: https://github.com/openhab/openhab-js/blob/main/CHANGELOG.md#581. Signed-off-by: Florian Hotze <[email protected]>
1 parent 8ea703e commit 9b4ee48

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

bundles/org.openhab.automation.jsscripting/README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -809,13 +809,20 @@ See [openhab-js : actions.NotificationBuilder](https://openhab.github.io/openhab
809809
The cache namespace provides both a private and a shared cache that can be used to set and retrieve data that will be persisted between subsequent runs of the same or between scripts.
810810
811811
The private cache can only be accessed by the same script and is cleared when the script is unloaded.
812-
You can use it to store both primitives and objects, e.g. store timers or counters between subsequent runs of that script.
812+
You can use it to store primitives and objects, e.g. store timers or counters between subsequent runs of that script.
813813
When a script is unloaded and its cache is cleared, all timers (see [`createTimer`](#createtimer)) stored in its private cache are automatically cancelled.
814814
815815
The shared cache is shared across all rules and scripts, it can therefore be accessed from any automation language.
816816
The access to every key is tracked and the key is removed when all scripts that ever accessed that key are unloaded.
817817
If that key stored a timer, the timer will be cancelled.
818-
You can use it to store **only primitives**, as storing objects is not thread-safe and can cause script execution failures.
818+
You can use it to store primitives and **Java** objects, e.g. store timers or counters between multiple scripts.
819+
820+
Due to a multi-threading limitation in GraalJS (the JavaScript engine used by JavaScript Scripting), it is not recommended to store JavaScript objects in the shared cache.
821+
Multi-threaded access to JavaScript objects will lead to script execution failure!
822+
You can work-around that limitation by either serialising and deserialising JS objects or by switching to their Java counterparts.
823+
824+
Timers as created by [`createTimer`](#createtimer) can be stored in the shared cache.
825+
The ids of timers and intervals as created by `setTimeout` and `setInterval` cannot be shared across scripts as these ids are local to the script where they were created.
819826
820827
See [openhab-js : cache](https://openhab.github.io/openhab-js/cache.html) for full API documentation.
821828
@@ -1240,7 +1247,7 @@ Operations and conditions can also optionally take functions:
12401247
12411248
```javascript
12421249
rules.when().item("F1_light").changed().then(event => {
1243-
console.log(event);
1250+
console.log(event);
12441251
}).build("Test Rule", "My Test Rule");
12451252
```
12461253

bundles/org.openhab.automation.jsscripting/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<!-- Remember to check if the fix https://github.com/openhab/openhab-core/pull/4437 still works when upgrading GraalJS -->
2626
<graal.version>22.0.0.2</graal.version> <!-- DO NOT UPGRADE: 22.0.0.2 is the latest version working on armv7l / OpenJDK 11.0.16 & armv7l / Zulu 17.0.5+8 -->
2727
<oh.version>${project.version}</oh.version>
28-
<ohjs.version>[email protected].0</ohjs.version>
28+
<ohjs.version>[email protected].1</ohjs.version>
2929
</properties>
3030

3131
<build>

0 commit comments

Comments
 (0)