-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Pass options through to oncreate
#550
Comments
I admire the simplicity and power of svelte but did wonder about the lack of lifecycle events. Unless I'm misunderstanding this wouldn't a beforeCreate event to go with onCreate/afterCreate event be simpler? (likewise for destroy). Am assuming target node would be accessible in the updated onCreate/afterCreate. |
What would you do in a |
Had thought it might be the place to grab some data or prep work but it does seem to be redundant. Coming from Vue, had thought that with mounted and other LC events that additional svelte events may be needed. Ignore this please Rich and it's refreshing to keep things minimal. Don't think beforeCreate is used much in Vue after all! |
And here's a less magical, but still hack-ugly version that rolls its own Can we have this? <Counter ref:counter/>
<Component arguments="{ counter: this.refs.counter }"/> <!-- Component.html -->
<button on:click="counter.increment()">increment</button>
<script>
export default {
oncreate ({ counter }) {
this.counter = counter
}
} |
attach options to component (#550)
As of 1.34, you can access |
This has come up (most recently) once or twice in discussion — there are some situations where it would be helpful to be able to access the instantiation options in
oncreate
(though I don't think it's something we should encourage, it's a useful escape hatch).The text was updated successfully, but these errors were encountered: