Skip to content

A way to display data from external libraries reactively #15068

@eulertour

Description

@eulertour

Describe the problem

I have an AnimationController object which lets me pause, play, and seek through a canvas animation. The controller stores its data internally, but I want to display some of it reactively like the elapsed time and play/pause state in svelte.

I'm hoping to build an online editor which can display the attributes of any animated entity reactively so only a generalized solution is feasible. How can I handle this in svelte 5?

I've seen similar (the same?) issues that don't seem to have reached a consensus #10560, #11846, #14520, but I'm not asserting that svelte should handle this, only asking whether it can.

playground: https://svelte.dev/playground/a7b1bf2fb4d947eda4f72ebabd8b06e6?version=5.19.0

Describe the proposed solution

It'd be nice if there were a way to communicate to svelte that some attribute of a non-reactive library should be made reactive, e.g.

<script>
import AnimationController from "./AnimationController.js";
const animationController = new AnimationController();
</script>

<span>{$reactive(animationController.elapsedTime)}</span>

Importance

i cannot use svelte without it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions