@communecter/cocolight-api-client 1.0.38 → 1.0.39

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.39",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
@@ -186,6 +186,22 @@ 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
+ const signal = signals?.get(key);
199
+ if (!signal || !signal.subscribe) {
200
+ return () => {}; // no-op si le champ n'existe pas
201
+ }
202
+ return signal.subscribe(() => callback(signal.value));
203
+ }
204
+
189
205
  // --- Helpers internes ---
190
206
  function _getPathValue(obj, path) {
191
207
  return path.split(".").reduce((o, k) => (o ? o[k] : undefined), obj);