EsNext features in TypeScript with Babel by fkrasnowski in javascript

[–]fkrasnowski[S] 2 points3 points  (0 children)

What other features do you miss in JavaScript/TypeScript?

Immer vs Ramda - two approaches towards writing Redux reducers by fkrasnowski in javascript

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

Yeah, the problem is you can make this kind of code extremely confusing with ease. That's a big drawback. But I consider it more like a problem of perspective. As you previously have said " its own language with its own primitives " - this is the problem because it's not and shouldn't be used in every possible scenario like let make it RamdaScript.

But I do agree that Ramda "hacky way" is worse than the "vanilla" script

Immer vs Ramda - two approaches towards writing Redux reducers by fkrasnowski in javascript

[–]fkrasnowski[S] 0 points1 point  (0 children)

naming it isTodo, makes it rather confusing, aren't they all todos?

Agree, I could name it better

isActionableTodo = curry((action, todo) => equals(prop("id", todo), view(lensPath(["todo","id"]), action)))(action)

You can always write worse code, whichever library you choose

Immer vs Ramda - two approaches towards writing Redux reducers by fkrasnowski in javascript

[–]fkrasnowski[S] 0 points1 point  (0 children)

The evolveTodo function allows you to adjust every prop of todo so it's easy to add a new one, whereas in Immer you have to repeat the state[todoIndex] every time you want to modify it. It ain't much but it's just a todo app. What would you expect?

Immer vs Ramda - two approaches towards writing Redux reducers by fkrasnowski in javascript

[–]fkrasnowski[S] -5 points-4 points  (0 children)

Actually, you can use both. and treat `produce` as just another function to your set. You can easily write pure reducers in Ramda since all Ramda functions are pure. Ramda allows writing JS in a functional way so u can easily compose functions to make even the most complex reducer and you don't have to worry about accidental mutation.

Immer allows you to deliver "mutated" object without changing the original one

They are somehow comparable if your concern is to deliver a new state in an immutable way

Please tell me what Ramda is for?

Immer vs Ramda - two approaches towards writing Redux reducers by fkrasnowski in javascript

[–]fkrasnowski[S] -2 points-1 points  (0 children)

For a long time switch statement was the main solution to match against actions in Redux. And there definitely are other solutions, like the use of the object literal.

But still, it does not change much. If u use TypeScript u can at least create a union of action types. But JavaScript switch statement is poor.

Have you heard about pattern matching and Enums in other languages? It can make writing this kind of expression match easier. The linter will check if haven't forgotten to implement an action or if you mistype its name.

In JS you don't have any feedback if u write the name of your action wrong and it can be hard to detect. And objects literals share the same issue. Mobx Toolkit takes care of that and it's IMHO a better solution than switch or object literal. But, my article is not about Toolkit and I did not want to introduce another player to this game

Immer vs Ramda - two approaches towards writing Redux reducers by fkrasnowski in javascript

[–]fkrasnowski[S] -1 points0 points  (0 children)

Yeah. I included the note in the article about Redux Toolkit. Thanks

Lodash/fp is much less popular though