smastrom/vue-collapsed

use vue's events instead of binding callbacks

Alexnortung opened this issue · 1 comments

instead of having to bind the callbacks with props, why not just use vue's own emits?
So this:

    <Collapse
      :when="selected"
      :onExpanded="() => scrollIntoView(index)"
      class="v-collapse"
    >
      <p>
        Hello world
      </p>
    </Collapse>

would become this:

    <Collapse
      :when="selected"
      @expanded="() => scrollIntoView(index)"
      class="v-collapse"
    >
      <p>
        Hello world
      </p>
    </Collapse>

This seems more intuitive when working with vue (at least to me).

Hi @Alexnortung, I can totally understand that events feels more natural for some people, I choose the 'prop' approach because (at least for me) they integrate better with the IDE (autocomplete, type definition) but also because they're nothing else than a callback passed from the parent to child. Collapse is actually not exposing any data to the parent, the callback is just a () => void function that Collapse receives and executes at some point.

However, we might integrate them (but without removing the props), feel free to submit a PR and I'll merge it and update the README accordingly.

Have a nice day!