-
Notifications
You must be signed in to change notification settings - Fork 201
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
Add reactive destructuring to cheatsheet #211
base: main
Are you sure you want to change the base?
Conversation
✔️ Deploy Preview for sveltesociety-preview ready! 🔨 Explore the source changes: 8db2c5b 🔍 Inspect the deploy log: https://app.netlify.com/sites/sveltesociety-preview/deploys/61e6d16254109100081c7e55 😎 Browse the preview: https://deploy-preview-211--sveltesociety-preview.netlify.app |
@@ -437,6 +437,8 @@ onMount(() => { | |||
alert('count is dangerously high!') | |||
count = 9 | |||
} | |||
|
|||
$: ({ab, cd, ef: {gh} = {gh: {}}} = alphabet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit hard to understand what you trying to do.
And furthermore, the code is "invalid": alphabet
is undefined
Something like that seem easier to understand:
$: ({ab, cd, ef: {gh} = {gh: {}}} = alphabet) | |
let myObject = {a: 10, b: 20, c: { d: "hello" }} | |
$: ({a, b, c} = myObject) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to make this code as difficult as possible to explain well what is possible to do.
Maybe the below is better?
let myObject = {a: 10, b: 20, c: { d: "hello" }}
$: ({a, b, c, e: {f} = {f: "default"}} = myObject)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if there are any themes being used in the cheatsheet, but one device I've seen work well is to explain things with super heroes. Otherwise, finding something with short identifiers (e.g. coordinates) might be more useful than asking the reader to assign identifiers meaning on the fly while trying to grok the concept.
No description provided.