@talismn/util 0.0.0-pr2075-20250709135256 → 0.0.0-pr2075-20250710032705
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.
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { OperatorFunction } from "rxjs";
|
2
2
|
/**
|
3
3
|
* An RxJS operator that keeps the source observable alive for a specified duration
|
4
4
|
* after all subscribers have unsubscribed. This prevents expensive re-subscriptions
|
@@ -14,4 +14,4 @@ import type { MonoTypeOperatorFunction } from "rxjs";
|
|
14
14
|
* );
|
15
15
|
* ```
|
16
16
|
*/
|
17
|
-
export declare const keepAlive: <T>(
|
17
|
+
export declare const keepAlive: <T>(timeout: number) => OperatorFunction<T, T>;
|
@@ -360,71 +360,23 @@ const getSharedObservable = (namespace, args, createObservable, serializer = arg
|
|
360
360
|
* );
|
361
361
|
* ```
|
362
362
|
*/
|
363
|
-
const keepAlive =
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
};
|
381
|
-
return new rxjs.Observable(subscriber => {
|
382
|
-
// Cancel any pending cleanup
|
383
|
-
if (cleanupTimer) {
|
384
|
-
clearTimeout(cleanupTimer);
|
385
|
-
cleanupTimer = null;
|
386
|
-
}
|
387
|
-
refCount++;
|
388
|
-
|
389
|
-
// Handle already completed/errored states
|
390
|
-
if (hasCompleted) {
|
391
|
-
subscriber.complete();
|
392
|
-
return () => {
|
393
|
-
refCount--;
|
394
|
-
};
|
395
|
-
}
|
396
|
-
if (hasErrored) {
|
397
|
-
subscriber.error(error);
|
398
|
-
return () => {
|
399
|
-
refCount--;
|
400
|
-
};
|
401
|
-
}
|
402
|
-
|
403
|
-
// Create source subscription if it doesn't exist
|
404
|
-
if (!sourceSubscription) {
|
405
|
-
sourceSubscription = source.subscribe({
|
406
|
-
next: value => {
|
407
|
-
subscriber.next(value);
|
408
|
-
},
|
409
|
-
error: err => {
|
410
|
-
hasErrored = true;
|
411
|
-
error = err;
|
412
|
-
subscriber.error(err);
|
413
|
-
},
|
414
|
-
complete: () => {
|
415
|
-
hasCompleted = true;
|
416
|
-
subscriber.complete();
|
417
|
-
}
|
418
|
-
});
|
419
|
-
}
|
420
|
-
return () => {
|
421
|
-
refCount--;
|
422
|
-
if (refCount === 0) {
|
423
|
-
cleanupTimer = setTimeout(cleanup, keepAliveMs);
|
424
|
-
}
|
425
|
-
};
|
426
|
-
});
|
427
|
-
};
|
363
|
+
const keepAlive = timeout => {
|
364
|
+
let release;
|
365
|
+
return source => source.pipe(rxjs.tap({
|
366
|
+
subscribe: () => {
|
367
|
+
release = keepSourceSubscribed(source, timeout);
|
368
|
+
},
|
369
|
+
unsubscribe: () => {
|
370
|
+
release?.();
|
371
|
+
}
|
372
|
+
}), rxjs.shareReplay({
|
373
|
+
refCount: true,
|
374
|
+
bufferSize: 1
|
375
|
+
}));
|
376
|
+
};
|
377
|
+
const keepSourceSubscribed = (observable, ms) => {
|
378
|
+
const sub = observable.subscribe();
|
379
|
+
return () => setTimeout(() => sub.unsubscribe(), ms);
|
428
380
|
};
|
429
381
|
|
430
382
|
exports.BigMath = BigMath;
|
@@ -360,71 +360,23 @@ const getSharedObservable = (namespace, args, createObservable, serializer = arg
|
|
360
360
|
* );
|
361
361
|
* ```
|
362
362
|
*/
|
363
|
-
const keepAlive =
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
};
|
381
|
-
return new rxjs.Observable(subscriber => {
|
382
|
-
// Cancel any pending cleanup
|
383
|
-
if (cleanupTimer) {
|
384
|
-
clearTimeout(cleanupTimer);
|
385
|
-
cleanupTimer = null;
|
386
|
-
}
|
387
|
-
refCount++;
|
388
|
-
|
389
|
-
// Handle already completed/errored states
|
390
|
-
if (hasCompleted) {
|
391
|
-
subscriber.complete();
|
392
|
-
return () => {
|
393
|
-
refCount--;
|
394
|
-
};
|
395
|
-
}
|
396
|
-
if (hasErrored) {
|
397
|
-
subscriber.error(error);
|
398
|
-
return () => {
|
399
|
-
refCount--;
|
400
|
-
};
|
401
|
-
}
|
402
|
-
|
403
|
-
// Create source subscription if it doesn't exist
|
404
|
-
if (!sourceSubscription) {
|
405
|
-
sourceSubscription = source.subscribe({
|
406
|
-
next: value => {
|
407
|
-
subscriber.next(value);
|
408
|
-
},
|
409
|
-
error: err => {
|
410
|
-
hasErrored = true;
|
411
|
-
error = err;
|
412
|
-
subscriber.error(err);
|
413
|
-
},
|
414
|
-
complete: () => {
|
415
|
-
hasCompleted = true;
|
416
|
-
subscriber.complete();
|
417
|
-
}
|
418
|
-
});
|
419
|
-
}
|
420
|
-
return () => {
|
421
|
-
refCount--;
|
422
|
-
if (refCount === 0) {
|
423
|
-
cleanupTimer = setTimeout(cleanup, keepAliveMs);
|
424
|
-
}
|
425
|
-
};
|
426
|
-
});
|
427
|
-
};
|
363
|
+
const keepAlive = timeout => {
|
364
|
+
let release;
|
365
|
+
return source => source.pipe(rxjs.tap({
|
366
|
+
subscribe: () => {
|
367
|
+
release = keepSourceSubscribed(source, timeout);
|
368
|
+
},
|
369
|
+
unsubscribe: () => {
|
370
|
+
release?.();
|
371
|
+
}
|
372
|
+
}), rxjs.shareReplay({
|
373
|
+
refCount: true,
|
374
|
+
bufferSize: 1
|
375
|
+
}));
|
376
|
+
};
|
377
|
+
const keepSourceSubscribed = (observable, ms) => {
|
378
|
+
const sub = observable.subscribe();
|
379
|
+
return () => setTimeout(() => sub.unsubscribe(), ms);
|
428
380
|
};
|
429
381
|
|
430
382
|
exports.BigMath = BigMath;
|
package/dist/talismn-util.esm.js
CHANGED
@@ -2,7 +2,7 @@ import { u8aToHex, u8aConcat, u8aToU8a, hexToU8a } from '@polkadot/util';
|
|
2
2
|
import { blake2AsU8a, isEthereumAddress as isEthereumAddress$1, ethereumEncode, decodeAddress as decodeAddress$1, base58Decode, checkAddressChecksum, xxhashAsU8a } from '@polkadot/util-crypto';
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
4
4
|
import { encodeAddress, decodeAddress } from '@polkadot/keyring';
|
5
|
-
import { concat, take, skip, debounceTime, shareReplay,
|
5
|
+
import { concat, take, skip, debounceTime, shareReplay, tap } from 'rxjs';
|
6
6
|
import BigNumber from 'bignumber.js';
|
7
7
|
|
8
8
|
const addTrailingSlash = url => {
|
@@ -354,71 +354,23 @@ const getSharedObservable = (namespace, args, createObservable, serializer = arg
|
|
354
354
|
* );
|
355
355
|
* ```
|
356
356
|
*/
|
357
|
-
const keepAlive =
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
};
|
375
|
-
return new Observable(subscriber => {
|
376
|
-
// Cancel any pending cleanup
|
377
|
-
if (cleanupTimer) {
|
378
|
-
clearTimeout(cleanupTimer);
|
379
|
-
cleanupTimer = null;
|
380
|
-
}
|
381
|
-
refCount++;
|
382
|
-
|
383
|
-
// Handle already completed/errored states
|
384
|
-
if (hasCompleted) {
|
385
|
-
subscriber.complete();
|
386
|
-
return () => {
|
387
|
-
refCount--;
|
388
|
-
};
|
389
|
-
}
|
390
|
-
if (hasErrored) {
|
391
|
-
subscriber.error(error);
|
392
|
-
return () => {
|
393
|
-
refCount--;
|
394
|
-
};
|
395
|
-
}
|
396
|
-
|
397
|
-
// Create source subscription if it doesn't exist
|
398
|
-
if (!sourceSubscription) {
|
399
|
-
sourceSubscription = source.subscribe({
|
400
|
-
next: value => {
|
401
|
-
subscriber.next(value);
|
402
|
-
},
|
403
|
-
error: err => {
|
404
|
-
hasErrored = true;
|
405
|
-
error = err;
|
406
|
-
subscriber.error(err);
|
407
|
-
},
|
408
|
-
complete: () => {
|
409
|
-
hasCompleted = true;
|
410
|
-
subscriber.complete();
|
411
|
-
}
|
412
|
-
});
|
413
|
-
}
|
414
|
-
return () => {
|
415
|
-
refCount--;
|
416
|
-
if (refCount === 0) {
|
417
|
-
cleanupTimer = setTimeout(cleanup, keepAliveMs);
|
418
|
-
}
|
419
|
-
};
|
420
|
-
});
|
421
|
-
};
|
357
|
+
const keepAlive = timeout => {
|
358
|
+
let release;
|
359
|
+
return source => source.pipe(tap({
|
360
|
+
subscribe: () => {
|
361
|
+
release = keepSourceSubscribed(source, timeout);
|
362
|
+
},
|
363
|
+
unsubscribe: () => {
|
364
|
+
release?.();
|
365
|
+
}
|
366
|
+
}), shareReplay({
|
367
|
+
refCount: true,
|
368
|
+
bufferSize: 1
|
369
|
+
}));
|
370
|
+
};
|
371
|
+
const keepSourceSubscribed = (observable, ms) => {
|
372
|
+
const sub = observable.subscribe();
|
373
|
+
return () => setTimeout(() => sub.unsubscribe(), ms);
|
422
374
|
};
|
423
375
|
|
424
376
|
export { BigMath, Deferred, MAX_DECIMALS_FORMAT, addTrailingSlash, blake2Concat, classNames, convertAddress, decodeAnyAddress, decodeSs58Format, encodeAnyAddress, firstThenDebounce, formatDecimals, formatPrice, getSharedObservable, hasOwnProperty, isAbortError, isAddressEqual, isArrayOf, isAscii, isBigInt, isBooleanTrue, isEthereumAddress, isNotNil, isTruthy, isValidSubstrateAddress, keepAlive, normalizeAddress, planckToTokens, sleep, throwAfter, tokensToPlanck, twox64Concat, validateHexString };
|