@sylphx/lens-solid 2.1.0 → 2.1.1
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/dist/index.js +30 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -425,10 +425,12 @@ class ClientImpl {
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
const resultOrObservable = this.transport.execute(processedOp);
|
|
428
|
+
let result;
|
|
428
429
|
if (this.isObservable(resultOrObservable)) {
|
|
429
|
-
|
|
430
|
+
result = await this.firstValueFrom(resultOrObservable);
|
|
431
|
+
} else {
|
|
432
|
+
result = await resultOrObservable;
|
|
430
433
|
}
|
|
431
|
-
let result = await resultOrObservable;
|
|
432
434
|
for (const plugin of this.plugins) {
|
|
433
435
|
if (plugin.afterResponse) {
|
|
434
436
|
result = await plugin.afterResponse(result, processedOp);
|
|
@@ -453,6 +455,32 @@ class ClientImpl {
|
|
|
453
455
|
isObservable(value) {
|
|
454
456
|
return value !== null && typeof value === "object" && "subscribe" in value && typeof value.subscribe === "function";
|
|
455
457
|
}
|
|
458
|
+
firstValueFrom(observable) {
|
|
459
|
+
return new Promise((resolve, reject) => {
|
|
460
|
+
let resolved = false;
|
|
461
|
+
const subscription = observable.subscribe({
|
|
462
|
+
next: (value) => {
|
|
463
|
+
if (!resolved) {
|
|
464
|
+
resolved = true;
|
|
465
|
+
subscription.unsubscribe?.();
|
|
466
|
+
resolve(value);
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
error: (err) => {
|
|
470
|
+
if (!resolved) {
|
|
471
|
+
resolved = true;
|
|
472
|
+
reject(err);
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
complete: () => {
|
|
476
|
+
if (!resolved) {
|
|
477
|
+
resolved = true;
|
|
478
|
+
reject(new Error("Observable completed without emitting a value"));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
}
|
|
456
484
|
getOperationMeta(path) {
|
|
457
485
|
if (!this.metadata)
|
|
458
486
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sylphx/lens-solid",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "SolidJS bindings for Lens API framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"author": "SylphxAI",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@sylphx/lens-client": "^2.
|
|
35
|
-
"@sylphx/lens-core": "^2.0
|
|
34
|
+
"@sylphx/lens-client": "^2.2.0",
|
|
35
|
+
"@sylphx/lens-core": "^2.1.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"solid-js": ">=1.8.0"
|