Skip to content
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

Discuss high level policy #7

Open
swyxio opened this issue Nov 1, 2020 · 4 comments
Open

Discuss high level policy #7

swyxio opened this issue Nov 1, 2020 · 4 comments

Comments

@swyxio
Copy link
Owner

swyxio commented Nov 1, 2020

  • what is our criteria for inclusion in this library?
  • I have chosen not to camelcase the action names as i feel it is more like an event ("lazyload") than a function ("lazyLoad"). does it matter?
  • what else?
@kindoflew
Copy link

Can the library be open to generic utility actions or should it be reserved for more specific use cases?

Example: I needed a conditional click listener action the other day and realized that it could just be a conditional anything listener. Something like this (based on clickOutside):

function conditionalEvent(node, {condition, event, cb}) {
    function update(condition) {    
        if (condition) {
            node.addEventListener(event, cb); 
        } else {
            node.removeEventListener(event, cb);
        }
    }

    update(condition);

    return {
        update,
        destroy() {
            node.removeEventListener(event, cb);
        }
    }
}

This is kind of a trivial example, but that's the general idea. Let people wire up their own logic, but the boilerplate is taken care of. The other Svelte built-ins don't have something like this (transition and animate), but actions can apply to so many things and those two are more specific in their applications.

@swyxio
Copy link
Owner Author

swyxio commented Jan 20, 2021

@kindoflew could you show a usage example? having trouble understanding how to use. in general am concerned about getting too meta too soon, but willing to consider if genuinely useful in many apps

@kindoflew
Copy link

This was just a generic example based off a use-case I had. I was submitting a PR (beyonk-group/svelte-carousel#56) to svelte-carousel. Basically, it's a carousel with an autoplay option and I needed to add a click-handler, but only if an autoplay duration was specified. My example above was a more generic version of that idea and might be useful for those writing libraries with components that have different needs depending on their configuration?

Anyway, my question was less about the example and more high-level asking about intent of the library I guess. In thinking of ideas for actions to submit/suggest I didn't know if they should be tailored to specific use cases or more like helper actions where the user would fill in the details. Not wanting to get too meta too soon kind of answers that though, I think.

@swyxio
Copy link
Owner Author

swyxio commented Jan 21, 2021

thanks, yea the idea is that this isn't a library so much as a prototype for what would fit in svelte by default. prone to some bikshedding ofc but also have to consider things like documentation and time to usefulness. could also serve as inspiration (what can we do with actions? well, look at the default ones!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants