Skip to content

Commit 7cc27d5

Browse files
committed
refactor(snackbar): use @alwatr/delay instead of @alwatr/wait
1 parent c8a041d commit 7cc27d5

File tree

5 files changed

+10
-36
lines changed

5 files changed

+10
-36
lines changed

packages/snackbar/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@
4646
"watch": "wireit"
4747
},
4848
"dependencies": {
49+
"@alwatr/delay": "^5.0.0",
4950
"@alwatr/flux": "^4.0.2",
5051
"@alwatr/logger": "^5.0.0",
5152
"@alwatr/package-tracer": "^5.0.0",
52-
"@alwatr/parse-duration": "^5.0.0",
53-
"@alwatr/wait": "^1.1.16",
5453
"@nexim/element": "^1.1.1",
5554
"lit": "^3.2.1"
5655
},
5756
"devDependencies": {
5857
"@alwatr/nano-build": "^5.0.0",
58+
"@alwatr/parse-duration": "^5.0.0",
5959
"@alwatr/type-helper": "^5.0.0",
6060
"@nexim/typescript-config": "^1.1.0",
6161
"ava": "^6.2.0",

packages/snackbar/src/lib/element.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {waitForTimeout} from '@alwatr/wait';
1+
import {delay} from '@alwatr/delay';
22
import {LightDomMixin, LoggerMixin} from '@nexim/element';
33
import {html, LitElement, nothing, type PropertyValues, type TemplateResult} from 'lit';
44
import {customElement, property} from 'lit/decorators.js';
@@ -55,7 +55,7 @@ export class SnackbarElement extends LightDomMixin(LoggerMixin(LitElement)) {
5555

5656
this.removeAttribute('open');
5757

58-
await waitForTimeout(SnackbarElement.openAndCloseAnimationDuration__);
58+
await delay.by(SnackbarElement.openAndCloseAnimationDuration__);
5959
this.remove();
6060
}
6161

packages/snackbar/src/lib/handler.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1+
import {delay} from '@alwatr/delay';
12
import {createLogger} from '@alwatr/logger';
2-
import {parseDuration} from '@alwatr/parse-duration';
3-
import {waitForTimeout} from '@alwatr/wait';
43

54
import {snackbarActionButtonClickedSignal, snackbarCloseButtonClickedSignal, snackbarSignal} from './signal.js';
65

@@ -107,7 +106,7 @@ async function showSnackbar(options: SnackbarOptions): Promise<void> {
107106

108107
// Set a timeout to close the snackbar if duration is not infinite
109108
if (options.duration !== 'infinite') {
110-
waitForTimeout(parseDuration(options.duration)).then(closeSnackbar);
109+
delay.by(options.duration).then(closeSnackbar);
111110
}
112111
}
113112

packages/snackbar/src/lib/utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {waitForAnimationFrame, waitForTimeout} from '@alwatr/wait';
1+
import {delay} from '@alwatr/delay';
22

33
/**
44
* Waits for the next frame to ensure the DOM has been fully calculated.
@@ -11,8 +11,8 @@ import {waitForAnimationFrame, waitForTimeout} from '@alwatr/wait';
1111
*/
1212
export function waitForNextFrame(): Promise<void> {
1313
return new Promise((resolve) => {
14-
waitForAnimationFrame().then(() => {
15-
waitForTimeout(0).then(resolve);
14+
delay.untilNextAnimationFrame().then(() => {
15+
delay.immediate().then(resolve);
1616
});
1717
});
1818
}

yarn.lock

+1-26
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,6 @@ __metadata:
141141
languageName: node
142142
linkType: hard
143143

144-
"@alwatr/global-scope@npm:^1.1.21":
145-
version: 1.1.26
146-
resolution: "@alwatr/global-scope@npm:1.1.26"
147-
dependencies:
148-
"@alwatr/package-tracer": "npm:^1.0.4"
149-
checksum: 10c0/d094cf6e1f0da79866cdde1abd45b073a4206c972ba274e57dd5fdc8a62db7fd4f5973360cfc2da03a8761cbd86bc9798f41fcf4a2ea5cf6b6b15f52a9f623a0
150-
languageName: node
151-
linkType: hard
152-
153144
"@alwatr/global-this@npm:^5.0.0":
154145
version: 5.0.0
155146
resolution: "@alwatr/global-this@npm:5.0.0"
@@ -257,13 +248,6 @@ __metadata:
257248
languageName: node
258249
linkType: hard
259250

260-
"@alwatr/package-tracer@npm:^1.0.4":
261-
version: 1.0.8
262-
resolution: "@alwatr/package-tracer@npm:1.0.8"
263-
checksum: 10c0/c9fe659a98c3225e8d3a188bd14e1dfd5ba2cc782a3faff689b54bd274419c0a4729a2785dd1304c549874f601e236bc0c570c3d2b12ca6c1d6ca5825f196747
264-
languageName: node
265-
linkType: hard
266-
267251
"@alwatr/package-tracer@npm:^5.0.0":
268252
version: 5.0.0
269253
resolution: "@alwatr/package-tracer@npm:5.0.0"
@@ -354,15 +338,6 @@ __metadata:
354338
languageName: node
355339
linkType: hard
356340

357-
"@alwatr/wait@npm:^1.1.16":
358-
version: 1.1.16
359-
resolution: "@alwatr/wait@npm:1.1.16"
360-
dependencies:
361-
"@alwatr/global-scope": "npm:^1.1.21"
362-
checksum: 10c0/3ac3af8b6c913a1f0414bc8893ac3ba0175a6e4e2732395a8f2ee263d3a2f65bb22bcfef78d57b611d00be0d75b9cf535ebf854c99db25b51cfd47e9d41e9b23
363-
languageName: node
364-
linkType: hard
365-
366341
"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.21.4, @babel/code-frame@npm:^7.22.13":
367342
version: 7.26.2
368343
resolution: "@babel/code-frame@npm:7.26.2"
@@ -1066,13 +1041,13 @@ __metadata:
10661041
version: 0.0.0-use.local
10671042
resolution: "@nexim/snackbar@workspace:packages/snackbar"
10681043
dependencies:
1044+
"@alwatr/delay": "npm:^5.0.0"
10691045
"@alwatr/flux": "npm:^4.0.2"
10701046
"@alwatr/logger": "npm:^5.0.0"
10711047
"@alwatr/nano-build": "npm:^5.0.0"
10721048
"@alwatr/package-tracer": "npm:^5.0.0"
10731049
"@alwatr/parse-duration": "npm:^5.0.0"
10741050
"@alwatr/type-helper": "npm:^5.0.0"
1075-
"@alwatr/wait": "npm:^1.1.16"
10761051
"@nexim/element": "npm:^1.1.1"
10771052
"@nexim/typescript-config": "npm:^1.1.0"
10781053
ava: "npm:^6.2.0"

0 commit comments

Comments
 (0)