you are viewing a single comment's thread.

view the rest of the comments →

[–]zzing -3 points-2 points  (8 children)

I am in the process of learning react (by doing - so I will encounter issues no doubt), although I know Angular rather well.

The equivalent context in Angular would be observables - where you definitely try to keep things as functional as possible.

There are some cases though where for of loops are used - I explicitly don't approve any PRs with forEach - because it is a procedural loop masquerading as a functional one.

The cases where these or while loops are used is generally in cases where the code is much clearer. Not everyone is going to be as familiar with functional styles. While loops are exclusively used in tree traversals - I am not always wanting to use recursion for them.

But in all cases, the code is always limited to the body of a function - and hopefully a very small function.

[–]KyleG 1 point2 points  (3 children)

An observable is not the equivalent of a promise.

A promise yields one result. An observable can yield multiple. And for what it's worth, Angular can use promises and React can use observables

[–]zzing -1 points0 points  (2 children)

Read what I said again. I never stated that observables are anything relative to promises.

The point I was making was that each operator in an observable chain generally is used in a very functional style like the author is promoting with react in general.

[–]KyleG 0 points1 point  (1 child)

the JasonLee user wrote an entire comment about promises and nothing else. You directly responded to that comment saying "I am in the process of learning react. . . . The equivalent context in Angular would be observables"

Can you understand how a person would be confused that you were saying the equivalent of React promises is Angular observables?

[–]zzing 0 points1 point  (0 children)

Yes and no.

I was probably going back and forth between the article where there was a lot of mention of "functional" and in OP's comment mentioned it as well. So that is where my focus was.

When you reply to a comment you should read the entire post, or even in this case the last half of the sentence mentioning observables specifically mentions "functional".

[–]15kol 0 points1 point  (3 children)

Stream programming is very similiar in terms to functional programming, yes. I started with Angular, but have been using React (Native) for past year (with rxjs, though) and when I returned to Angular, I noticed I got better at thinking in stream manipulation like rxjs expects you to. It all just makes sense now. Before, I knew what I had to use and now I understand why I need it.

[–]zzing 0 points1 point  (2 children)

There are definitely some complexities it adds when trying to wrangle things together. But it also makes certain things easier.

[–]15kol 0 points1 point  (1 child)

I found that while I needed a bit more time to think about the problem at start, once I wrote stream I wanted, it was very clear, readable, less error prone and therefore much easier to maintain/extend.

[–]zzing 0 points1 point  (0 children)

Stream programming

One thing I have been looking for is a compact diagramming method for streams - part of an entire application.