woutdp / live_svelte

Svelte inside Phoenix LiveView with seamless end-to-end reactivity
https://hexdocs.pm/live_svelte
MIT License
1.02k stars 38 forks source link

Autoreload nodejs supervisor in dev on svelte component change #8

Closed woutdp closed 1 year ago

woutdp commented 1 year ago

Maybe possible with:

    notify: [
      live_svelte: [~r"priv/static/assets/server/.*(js|css)$"],
    ]

which will send an event

{:phoenix_live_reload, :live_svelte, "the/path/of/the/file/that/changed"},

And then catching the message in the supervisor and restarting the workers

Testing it out by running:

alias Phoenix.PubSub 
PubSub.subscribe(PhoenixBlank.PubSub, "live_svelte")
# Trigger the event by changing a file
Process.info(self(), :messages)
woutdp commented 1 year ago

Instead of resetting the supervisor, we simply delete the cache in the SSR server render function