Release of Mithril 1.0
21–30 of 31 posts
Re: Release of Mithril 1.0
#22Earlier quoted context omitted.
Is redux considered "standard" in react land? I thought a lot of projects don't make use of it.
Redux is an opinionated implementation of the SAM pattern for React. The same pattern can be seen in the Elm Architecture. • http://sam.js.org Now, I don't know how old this pattern is, or whether it was already commonplace 15 years ago. I was introduced to these ideas first through Redux, then learned Elm, the found SAM.
Re: Release of Mithril 1.0
#23Does Mithril implement something akin to Redux? Otherwise, I'd argue that those graphs related to size aren't quite correct. Also, fetch isn't required for either React or Vue.js, could certainly just use the built XHR API to get down even further.
Re: Release of Mithril 1.0
#24For a stateless component which is implemented as a pure function, where you would normally write:
myPText(myText) {
return {myText}
}
In mithril you would write: myPText(myText) {
return m("p", myText)
}
So the same vein of thinking can take you pretty far, but the benefit is that everything is Javascript so there is less context switching between framework and language!EDIT: code snippet
Re: Release of Mithril 1.0
#25Earlier quoted context omitted.
Is redux considered "standard" in react land? I thought a lot of projects don't make use of it.
Redux is an opinionated implementation of the SAM pattern for React. The same pattern can be seen in the Elm Architecture. • http://sam.js.org Now, I don't know how old this pattern is, or whether it was already commonplace 15 years ago. I was introduced to these ideas first through Redux, then learned Elm, the found SAM.
Re: Release of Mithril 1.0
#26Earlier quoted context omitted.
Is redux considered "standard" in react land? I thought a lot of projects don't make use of it.
Redux is an opinionated implementation of the SAM pattern for React. The same pattern can be seen in the Elm Architecture. • http://sam.js.org Now, I don't know how old this pattern is, or whether it was already commonplace 15 years ago. I was introduced to these ideas first through Redux, then learned Elm, the found SAM.
SAM fixes three approximations that we have been using in Software Engineering for Decades:
- actions can manipulate application state
- assignments are equivalent to mutation
- there is no need to define precisely what is a programming step (for instance when you write a = b + c, is that a step or is it 3 steps: read b,c, compute b+c, mutate the value of a)
To a certain degree, Redux and Elm are trying to address these three approximations as well, but they do it from a FP point of view, not from a TLA+ point of view.
Their definition of action aligns with the one of event and their approach to mutation is immutability. The main difference between SAM and Redux/Elm is the way side-effects are treated. SAM embraces side-effects (in particular asynch calls) while Redux/Elm don't know how to deal with them. Redux for instance breaks its principle #1 (single state tree) by introducing Sagas.
SAM is a factoring of your code that fits in one line of code: V = State(Model.present(Action(event))).then(nextAction)
No need for a nebula of libraries or inventing a whole new language.
Re: Release of Mithril 1.0
#27Earlier quoted context omitted.
Redux is an opinionated implementation of the SAM pattern for React. The same pattern can be seen in the Elm Architecture. • http://sam.js.org Now, I don't know how old this pattern is, or whether it was already commonplace 15 years ago. I was introduced to these ideas first through Redux, then learned Elm, the found SAM.
It is not, almost everything can follow SAM patern, but Redux, as is used by everyone, doesn't follow the pattern.
Re: Release of Mithril 1.0
#28I was looking at upgrading it to Mithril 1.0 this past weekend, but new Cljs release's new JS support landed just then. So, now I'm trying to deduce how to get my upgraded build configuration working again...
I believe you can pretty much write Mithril with Lisp/Clojure flawor:
(nm "div"
[(nm "h1" "Mithril app with data persistence")
(nm "div" username)
(nm "div" [(text "username" username 40 #(update :username %))
(nm "button.pure-button" {:onclick #(persist)} "Persist")])
(nm "div" [(nm "textarea" {"rows" 10 "cols" 40} (get-item "data"))]))
Router and XHR/Ajax also work. I haven't yet used Mithril's components, but with 1.0 those too seem more straightforward.Re: Release of Mithril 1.0
#29Earlier quoted context omitted.
Is redux considered "standard" in react land? I thought a lot of projects don't make use of it.
Redux is an opinionated implementation of the SAM pattern for React. The same pattern can be seen in the Elm Architecture. • http://sam.js.org Now, I don't know how old this pattern is, or whether it was already commonplace 15 years ago. I was introduced to these ideas first through Redux, then learned Elm, the found SAM.
Re: Release of Mithril 1.0
#30This is a pretty cool library, for the people coming from React, the context switch for creating components needs not be so great: For a stateless component which is implemented as a pure function, where you would normally write: myPText(myText) { return {myText} } In mithril you would write: myPText(myText) { return m("p", myText) } So the same vein of thinking can take you pretty far, but the benefit is that everyt…
Reference: http://mithril.js.org/jsx.html