<script composable> in Components #9133
fabianwohlfart
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Renderless Componentshttps://vuejs.org/guide/components/slots.html#scoped-slots <Upload v-slot="slotProps">
<File :file="slotProps.path"/>
</Upload> |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I often come to the point where I have the same component used in different parent components. For example let's say it's a
FileUpload
component. This FileUpload emits the uploaded file to it's parent. This parent has to handle the uploaded file, e.g. show it in a list. We have a different parent component for aFile
(pdf), anImage
(jpg) and aVideo
(mp4). So each of the parent components may use the same functionhandleUpload()
. While it's not smart to repeat ourself, we are writing a composable for this; maybe not only ahandleUpload()
, but also aprepareData()
and whatsoever. This composable now lies in a third file, away from the party (first file: child, second file: parent)…How would it be to have a
<script composable>
in a component which exposes the same of what a composable does but only to it's parents? I am aware that there are probably many caveats to this idea. On the other side: I always loved that SFC contain everything they need, and now my child component needs to expose functions to it's parent, which is only particular interesting for it's parents, not in the whole App.Beta Was this translation helpful? Give feedback.
All reactions