4 ms·
bind:group is explained in the docs (https://svelte.dev/tutorial/group-inputs https://svelte.dev/tutorial/group-inputs). I don't think React would be particular
by atan 7y ago
bind:group is explained in the docs (https://svelte.dev/tutorial/group-inputs https://svelte.dev/tutorial/group-inputs). I don't think React would be particularly easy to grok without first having read its docs (or some kind of instructional material) either. Regarding the "magic," note that you can always inspect the generated Javascript, which is quite readable (particularly in dev mode). Given that the component code is largely self-contained (it does refer to some common shared helper functions), you might even find it easier to understand how Svelte is working than trying to follow whatever the React library is doing behind the scenes.
- ng12 7y agoThat's not what I mean when I say "magic". Magic, to me, is having some special string in your template which is going to invoke some arbitrary logic to get something "just working". In this example, note how `group` does different things depending on what kind of input you're dealing with. That's the kind of stuff that sounds great in a demo but quickly becomes a pain in a large application. It's not about being able to learn a framework without reading the documentation, it's about how many distinct concepts you have to read the documentation for to use the framework. React is extremely conceptually light, by design, which is something I love about it.
- atan 7y agobind:group is not a "special string" but simply part of the API, in the same way useEffect is part of the React API. bind:group is no more "magical" than useEffect (both are ultimately going to "invoke some arbitrary logic"). > In this example, note how `group` does different things depending on what kind of input you're dealing with. That's the kind of stuff that sounds great in a demo but quickly becomes a pain in a large application. I really don't see how. It is relevant to exactly two kinds of inputs (radio and checkbox) and does exactly what you would expect with each (given the different behaviors of radio and checkbox inputs). > It's not about being able to learn a framework without reading the documentation, it's about how many distinct concepts you have to read the documentation for to use the framework. Sure, but looking at the right menu in the React documentation (https://reactjs.org/docs/getting-started.html https://reactjs.org/docs/getting-started.html), there are actually quite a lot of concepts and API details to understand in order to become proficient in writing React apps. I would be hard pressed to say that looks any lighter or simpler than Svelte (I would actually argue the opposite -- Svelte seems simpler and more straightforward).
- ng12 7y ago> bind:group is not a "special string" but simply part of the API Right, but the difference is in the API design. React gives you a small set of tools to implement whatever functionality you need. Svelte gives you specially-crafted tools which to handle specific scenarios. Svelte gives you a command to bind input groups to a stateful value, React gives you the tools to do it yourself. The difference is subtle but experience has lead me to vastly prefer the latter, mostly because you're less reliant on the framework designer getting everything "right". Here's a good talk which helps explain the difference: https://2014.jsconf.eu/speakers/sebastian-markbage-minimal-api-surface-area-learning-patterns-instead-of-frameworks.html https://2014.jsconf.eu/speakers/sebastian-markbage-minimal-a...
- atan 7y agoI think React gives you more specially-crafted tools than you suggest and Svelte gives you fewer than you suggest. Even in this case, bind:group is just a shortcut -- Svelte also provides the tools to "do it yourself" if you need that ability in some special case (see https://svelte.dev/repl/3cffb15ef71f43b08872f72c527089a2?version=3.9.2 https://svelte.dev/repl/3cffb15ef71f43b08872f72c527089a2?ver...).