News for hackers. Stuff that matters.
Re:Comparing Svelte and React by nsonha on Thursday March 25, 2021 @05:17PM (#26585496)
> transitions are not (but rather methods attached to states)

whose type signature has start and end state

> first-class entities

a string

Re:Comparing Svelte and React by dwohnitmok on Thursday March 25, 2021 @06:53PM (#26586655)
> whose type signature has start and end state

As do the reducers. For example the following is a valid type signature.

  function onToOff(initialState: "on", transition: "toggle"): "off"
In each of the if clauses those are what the types are inferred as, exactly equivalent in type safety to the classes (and more flexible because you can dispatch on action).

I chose string for simplicity (string literals happen to be distinct types on their own, I could easily use anything else other than strings, e.g. interfaces). Heck it could just be integers and be even simpler.

Re:Comparing Svelte and React by nsonha on Thursday March 25, 2021 @08:34PM (#26587525)
wow a typescript lesson, because no one's ever heard of this

> Heck it could just be integers and be even simpler.

statement that has zero point, why make them?

> As do the reducers

like this? A | B | C => B | C | D

does that look like a state machine? Because state machine is this A => B & B => C & C => D