-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
more svelte action ideas #13
Comments
devon govett suggests the hooks from his React Aria package https://github.com/adobe/react-spectrum/tree/main/packages/@react-aria/interactions/src |
Since Svelte does not have a way to forward all the events from a DOM node (e.g., I came up with an action, that will open up an react-alike API for events.
<script>
import { subscribeToEvents } from './utils.js';
export let events;
</script>
<div use:subscribeToEvents={events}>
Hey
</div>
<script>
import Child from './Child.svelte';
const events = new Map();
events.set('mouseover', () => console.log('mouseover'))
events.set('click', () => console.log('click'))
</script>
<Child {events} /> I can update it to look better, but the idea stands. |
thank you for suggesting! this usecase looks a bit a bit abstract imo. mostly useful for library builders? would prefer to document in recipes then unless there is more popular demand. |
@sw-yx I'm on the same page with you. I came up with this action while discussing Svelte's potential with React folks, I have yet to find a single use-case in my real-world practice for it. But I was told by the same React folks that every major company creates an in-house UI Kit, and being unable to work with events predictably pushes them away from adopting Svelte. I'm not sure if this belongs in this repo, recipes, tutorials or whatever. For now other guy from the same chat put the solution on the corresponding feature request on Svelte's main repo, hopefully it'll help someone. |
Is there a way to extract the |
@jthegedus this maaaybe could be interesting - do you think most routers would have an opinion on how to do active links though? i'm sure if we wanted to we could extract it, just want to make sure it is useful by most. i think this is ok... |
Beautiful idea! Revising how I achieved this in my project can't help but think an action would be more reusable. But just compare the code required for this task. It's monstrous for a reusable solution and barely 4 LOC for a sapper-specific one. Makes me think if it would really be useful. |
Most routers will certainly have an opinionated way of doing this. The fact that not all routers come with this action standard is the real issue. Is there a way to ensure that SvelteKit/all Svelte routers come with this action? Although Sapper only needs a 4LOC implementation as @dkzlv notes, it's 4 lines people have to lookup, understand, implement, and maintain as the router changes over time. I just want |
i think its a valid thing to want. i have no insider info on what sveltekit will offer. we definitely dont have any dictat on what routers will have this action. You know what - I'll add this to readme for now. can add if we have popular demand/once sveltekit comes out and doesnt have it. |
https://mobile.twitter.com/lihautan/status/1350083142833487874/photo/1
The text was updated successfully, but these errors were encountered: