@csedl/svelte-on-rails
v7.1.2
Published
Mounts Svelte components from the svelte-on-rails gem and handles Actions received by Web Socket.
Readme
@csedl/svelte-on-rails
Works together with the svelte-on-rails gem.
Prerequisites
- Please follow the gem instructions.
- Svelte >= 5
- tested with ruby 3.2.2 and rails 7.1
Installation
npm i @csedl/svelte-on-railsAdd to your entrypoint file, like application.js
import '@csedl/svelte-on-rails';For configs you can do
import { SvelteOnRails } from '@csedl/svelte-on-rails'
SvelteOnRails.debug = trueThe SvelteOnRails Object is accessible by window.SvelteOnRails
What it contains or does
- It includes a stimulus controller that handles the initializing event of the svelte component, rendered by the ruby gem. Initializing means that the component is mounted or hydrated, together with the properties given by the ruby gem.
- After disappearing, the component is unmounted by the disconnect event of stimulus.
Turbo-Streams
- For working with
Turbo Streamsit contains a stimulus controller that dispatches actions on Svelte Components. - Helper for adding eventListeners on Svelte Components.
Options
by setting
window.debugSvelteOnRailsComponents = trueyou have a console log of the component initialization and disconnection.
