Skip to content

Feature: subscribe callback from ProxyComponent #57

Open
@typhonrt

Description

@typhonrt

Hi @rixo et al.

I'm working full time+ on a desktop app like UI library for Svelte and have now been testing w/ the latest Vite & HMR. Each "application" has an external JS class reference that mounts a Svelte component; think the outer application window / header bar. This external class controls closing the window and positional aspects. HMR currently works fine for children components of the main mounted Svelte component for the app window. However, for refreshes in the main mounted component for each app window I need to receive a specific callback in the outer JS application class to update the mounted element reference and component details and hook it up to the existing position store that is located in the external class.

I have followed the Svelte store subscriber mechanism in ProxyComponent adding a single subscribe method that returns an unsubscribe function. I am aware that the ideal contract of ProxyComponent doesn't add any methods as it passes through everything to the wrapped actual Svelte component. I would be more than glad to discuss alternatives.

I have verified that the changes I have made in my fork pass all tests and that this feature solves my problem. I haven't added any new tests yet or made a formal PR as I'd like to discuss these proposed changes:
https://github.com/typhonjs-svelte/svelte-hmr
https://github.com/typhonjs-svelte/svelte-hmr/commit/9cc56aebb3342071065b119a744c203478cbce68

Just for some background here is a dev snapshot overview that shows my desktop app UI library in action. Presently I'm developing this UI library on the Foundry VTT TTRPG platform, but also plan to make it generally available to Svelte community in the near future for any app dev purposes.
https://www.youtube.com/watch?v=yIc0fYh1YGM&t

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