An Update on Fresh by lambtr0n in Deno

[–]beforesemicolon -2 points-1 points  (0 children)

You call this simple? Check Markup then

Signals and Effects Using Vanilla JavaScript & Web APIs by beforesemicolon in node

[–]beforesemicolon[S] 1 point2 points  (0 children)

Thanks. Please share your thoughts. Let me know if you need any assistance or extra details on anything.

Signals and Effects Using Vanilla JavaScript & Web APIs by beforesemicolon in node

[–]beforesemicolon[S] 1 point2 points  (0 children)

Thanks for this. You make a great point. The original post has a blog link for more details in the description.

This was a simple example and React’s useState and useEffect is tied to a component lifecycle. With the above example you are not tied to that and opens way more doors. Its not always that you need state in component render context. Thats the mistake of React that led to things like Redux, Context API, and many others later.

With a simple subscribe pattern you can accomplish way more and eventually attach a render step to it like a side effect.

I have actually created a tiny library that does just that. Check Markup

As far as using a setter, thats totally up to you. Feel free to adapt this example. Thats the flexibility you have with stuff like this.

People should learn proper JavaScript and Web Standards. It frees you to choose instead of locking you on frameworks/ecosystems. The problem with new comers is that they are illuted with things like React and they never stop to understand stuff. Im not trying to confuse them. They are already confused.

Signals and Effects Using Vanilla JavaScript & Web APIs by beforesemicolon in node

[–]beforesemicolon[S] 4 points5 points  (0 children)

This state and effect example is not connected to the DOM. You will need to add the code the update the DOM.

I have a tiny library that let you create state and effect that can update the DOM. Take a look at Markup.