@communecter/cocolight-api-client 1.0.38 → 1.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@communecter/cocolight-api-client",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
@@ -143,7 +143,7 @@ export function reactive(obj) {
143
143
  * @returns {boolean}
144
144
  */
145
145
  export function isReactive(obj) {
146
- return !!obj?.__isReactive;
146
+ return obj !== null && typeof obj === "object" && obj.__isReactive === true;
147
147
  }
148
148
 
149
149
  /**
@@ -186,6 +186,20 @@ export function getSignals(obj) {
186
186
  return signalRegistry.get(obj);
187
187
  }
188
188
 
189
+ /**
190
+ * Permet à React de s'abonner à une propriété réactive (champ simple).
191
+ * @param {object} obj - Objet réactif
192
+ * @param {string} key - Nom de la propriété à écouter
193
+ * @param {(newValue: any, oldValue: any) => void} callback
194
+ * @returns {() => void} fonction de nettoyage
195
+ */
196
+ export function subscribeTo(obj, key, callback) {
197
+ const signals = getSignals(obj);
198
+ if (!signals || !signals.has(key)) return () => {};
199
+ const signal = signals.get(key);
200
+ return signal?.subscribe?.(() => callback(signal.value)) ?? (() => {});
201
+ }
202
+
189
203
  // --- Helpers internes ---
190
204
  function _getPathValue(obj, path) {
191
205
  return path.split(".").reduce((o, k) => (o ? o[k] : undefined), obj);