Skip to content

Adopt the Explicit Resource Management API #8973

@TheCymaera

Description

@TheCymaera

Describe the problem

The Explicit Resource Management API is nearing Stage 4 and is implemented in TypeScript 5.2

I propose that Svelte 5 make use of patterns added by this proposal.

Describe the proposed solution

Specifically, we could use Symbol.dispose instead of $destroy

const svelteComponent = new MyComponent(options);
svelteComponent.$destroy();

// becomes

const svelteComponent = new MyComponent(options);
svelteComponent[Symbol.dispose]();

Additionally, using declarations in the global scope of a script tag should be tied to the component's lifecycle.

using resource = createResource();

// same as

const resource = createResource();
onDestroy(() => {
    resource[Symbol.dispose]();
});

Alternatives considered

NA

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy