Skip to content

Commit 64e5b0f

Browse files
committed
Revert "feat(async-stack): expose StackItem.msToTimeout as a public rune" (not helpful)
This reverts commit 44b8343.
1 parent 8e74a33 commit 64e5b0f

3 files changed

Lines changed: 11 additions & 15 deletions

File tree

.changeset/fair-goats-camp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@svelte-put/async-stack': patch
3+
---
4+
5+
revert `StackItem.msToTimeout` to internals as not helpful to public users

packages/async-stack/src/stack-item.svelte.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ export class StackItem<
1111
/** @default 'idle' */
1212
state: StackItemState;
1313
config: Required<StackItemInstanceConfig<string, UserComponent>>;
14-
/**
15-
* milliseconds until the item is timeouted,
16-
* 0 means the item has already timeouted or has no timeouted
17-
* (check config.timeout for more information)
18-
*/
19-
msToTimeout: number;
2014
/**
2115
* a promise that resolves when the item is resolved,
2216
* by timing out or via the .resolve method

packages/async-stack/src/stack-item.svelte.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ export class StackItem {
1111
/** @type {Required<import('./types.package').StackItemInstanceConfig<string, UserComponent>>} */
1212
config;
1313

14-
/** @type {number} */
15-
// eslint-disable-next-line no-undef
16-
msToTimeout = $state(0);
17-
1814
#internals = {
15+
msToTimeout: 0,
1916
/** @type {ReturnType<typeof setTimeout> | undefined} */
2017
timeoutId: undefined,
2118
lastStartedTime: new Date().getTime(),
@@ -33,29 +30,29 @@ export class StackItem {
3330
*/
3431
constructor(config) {
3532
this.config = config;
36-
this.msToTimeout = config.timeout;
33+
this.#internals.msToTimeout = config.timeout;
3734

3835
this.resolution = new Promise((resolve) => {
3936
this.#internals.resolve = resolve;
4037
});
4138
}
4239

4340
resume = () => {
44-
if (this.msToTimeout <= 0 || this.state === 'elapsing') return;
41+
if (this.#internals.msToTimeout <= 0 || this.state === 'elapsing') return;
4542
clearTimeout(this.#internals.timeoutId);
4643
this.#internals.lastStartedTime = new Date().getTime();
4744
this.#internals.timeoutId = setTimeout(async () => {
48-
this.msToTimeout = 0;
45+
this.#internals.msToTimeout = 0;
4946
await this.resolve();
5047
this.state = 'timeout';
51-
}, this.msToTimeout);
48+
}, this.#internals.msToTimeout);
5249
this.state = 'elapsing';
5350
};
5451

5552
pause = () => {
5653
if (this.state === 'paused' || this.state === 'idle') return;
5754
clearTimeout(this.#internals.timeoutId);
58-
this.msToTimeout -= new Date().getTime() - this.#internals.lastStartedTime;
55+
this.#internals.msToTimeout -= new Date().getTime() - this.#internals.lastStartedTime;
5956
this.state = 'paused';
6057
};
6158

0 commit comments

Comments
 (0)