Grainular-Nord / nord

A lightweight (8kb), dependency-free JavaScript Frontend Framework
https://nordjs.dev
MIT License
7 stars 0 forks source link

[FEATURE ENHANCEMENT] Suspense Directive #70

Closed IamSebastianDev closed 9 months ago

IamSebastianDev commented 9 months ago

Feature Enhancement Description

Feature Overview: A suspense directive could be used to improve displaying async data. Suspense components / directives are commonplace in other frameworks.

Current Functionality: There is no such functionality in Nørd

Suggested Enhancement: Creating a suspend or suspended directive, that will take a Promise as argument and resolve a specified template on resolution, with an optional fallback template until the promise resolves.

Benefits of Enhancement: This directive would greatly benefit async operations in Nørd

Additional Information

Possible Implementation 💡

const promise = new Promise<number>((res) => {
    setTimeout(() => {
        res(1)
    }, 500)
})

<div>
    ${resolve(promise)
        .then((data) => html`<div>${data}</div>`)
        .fallback(html`<div>...loading</div>`)
    }
</div>

Additional Context


github-actions[bot] commented 9 months ago

:tada: This issue has been resolved in version 1.11.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: