Dead simple State Management in Vanilla JavaScript
It's been years now since you started using Redux, MobX or even plain React Hooks and have no id...
For further actions, you may consider blocking this person and/or reporting abuse
Here is an optimised version :-)
You can test it here : SSMOPT
And if you want to get a little further
You can test it here IntroSamPattern
Hi @artydev- this is really interesting. I've not heard of the uthml package before. What exactly is it used/needed for vs the original package?
Thank you for your post.
Here is a variation :
You can test it here : SSM
Regards
This one is great. Makes better use of functional programming.
I don't want to come off sounding like an asshole, but is this satire?
It feels like someone whose never learnt JavaScript, and just copied react examples suddenly learnt how the language works... Unless I'm missing something fundamental.
Please, be comprehensive...
Are you sure you didn't want to come off sounding that way? I'm pretty sure you did.
Hi Vijay Pushkin,
I know this tutorial is not about the best code but I couldn't help myself from refactoring your code ;).
"app" in "app.innerHTML" has no reference, even though the code works perfectly. Can you please enlighten me? Pardon me me for being a novice. I was expecting something like app = document,getElementById("app")
Hey Afisunlu, totally a valid question:
Both
app
andtemplate
exist because each DOM node that has a definedid
attribute gets added to the globalwindow
object and therefore is able to be referenced without explicit initialization. This is part of the reason whyid
attributes should be unique for each DOM node in the tree.Try it with another DOM node and a different
id
!This is a nice explaination and it helps you understand the state management concept behind the scene. Good work 🙌
Hello,
here is the code of utml (877lines)
uhtml.js
You can test it here : uhtmltest
Optimized in a sense, it uses VDom Diff to update the page.
Regards
So happy to see some framework-agnostic content. This is a great read and shows sometimes we can get by just fine with the standard web technologies.
I was really wondering why you had _App and App but your justification is brillaint.
Vanilla javascript? I've never heard of that library.
Really into this, thank you for sharing! The cognitive burden of many frameworks is too high for what one gets in return.
I've found this routine to be helpful for rendering the state of arbitrary objects to the DOM. Additionally, when using standard HTML
template
tags, I've used another routine to populate slots (template parameters) and render the template at runtime.Great insight
Is your lastname really Pushkin? Like Alexander Sergeyevich Pushkin?
The place where I'm from, we don't have family names. So, yes both are my names!
Understood, cool. Pushkin is perhaps the greatest person in Russian literature. I am from Kazakhstan and we happen to speak and learn russian language at school. Anyways you have a great name!
Nice Insight on state management, waiting for the upcoming article.
When's the next article which I hope will be web components leverage native shadow Dom to handle updates when state changes :)
Nice article by the way. Good starting point.
Wow! 😮😍🥰 What an amazing tutorial! Now I can start writing my own front-end web framework. 😏😏😂😂 Just kidding, I won't! But I've always wanted to know how to. Thank you for the article! 💕💕
hey what does it mean when you add redraw in curly braces i.e return {redraw}. Please someone explain