Update example
This commit is contained in:
parent
39d5f51ee0
commit
bb1d672339
1 changed files with 14 additions and 13 deletions
27
README.md
27
README.md
|
@ -36,27 +36,28 @@ progress bar is removed once the delivery is complete:
|
|||
```typescript
|
||||
import postman, { item } from "postman";
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const progressBar = document.querySelector("progress");
|
||||
const bar = document.querySelector("progress");
|
||||
const span = document.querySelector(".percentage");
|
||||
postman(
|
||||
const delivery = postman(
|
||||
item.font("Kanit Regular", "url(/fonts/kanit-regular.ttf)"),
|
||||
item.script("/js/app.js"),
|
||||
item.image("/images/app.png"),
|
||||
item.css("/css/app.css"),
|
||||
item.progress((percent) => {
|
||||
progressBar.value = percent;
|
||||
bar.value = percent;
|
||||
span.innerText = `${percent}%`;
|
||||
})
|
||||
).deliver()
|
||||
.then((package) => {
|
||||
/* Add page assets */
|
||||
package.fonts.forEach((font) => documents.fonts.add(font));
|
||||
package.scripts.forEach((script) => document.body.appendChild(script));
|
||||
package.css.forEach((css) => document.head.appendChild(css));
|
||||
/* Replace progress bar */
|
||||
progressBar.remove();
|
||||
span.remove();
|
||||
});
|
||||
).deliver();
|
||||
|
||||
delivery.then((package) => {
|
||||
/* Add page assets */
|
||||
package.fonts.forEach((font) => documents.fonts.add(font));
|
||||
package.scripts.forEach((script) => document.body.appendChild(script));
|
||||
package.css.forEach((css) => document.head.appendChild(css));
|
||||
/* Replace progress bar */
|
||||
bar.remove();
|
||||
span.remove();
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue