• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Codemotion Magazine

Codemotion Magazine

We code the future. Together

  • Discover
    • Live
    • Tech Communities
    • Hackathons
    • Coding Challenges
    • For Kids
  • Watch
    • Talks
    • Playlists
    • Edu Paths
  • Magazine
    • AI/ML
    • Backend
    • Frontend
    • Dev Life
    • DevOps
    • Soft Skills
  • Talent
  • Partners
  • For Companies
Home » Frontend » Web Developer » RxJS and Angular Reactive Forms
Web Developer

RxJS and Angular Reactive Forms

In this article we interviewed Fabio Biondi to learn more about RxJS and Angular Reactive Forms.

Last update September 20, 2019 by Codemotion

Angular provides two different approaches to handle forms: template-driven forms, very simple to use and powerful, and Reactive Forms, based on Observable, much more flexible, scalable and robust.

In this article we will learn more about this by discovery Fabio Biondi‘s point of view, based on his talk delivered during Codemotion Rome 2019.

Why do we need ‘reactivity’ in JavaScript and what does it take to start reactive programming in JavaScript?

Reactive Programming is an “old” paradigm, but since the latest Angular version there has been development around this concept. By using the famous library RxJS, it has gained enormous popularity. Meanwhile, other frameworks and libraries have been developed around this concept.

Modern web and single page applications are highly interactive with a lot of UI events to handle, often connected to each other. Reactive Programming helps developers to handle these scenarios in the form of streams, focusing on the interdependence of events that define the business logic, rather than implementation. Furthermore, RxJS provides tons of utilities (dozens of operators, multicast, etc.) and you can now accomplish complex tasks in very few lines of code.

What are the main challenges for developers approaching to reactive programming for the first time?

Open their minds and think outside the box.

The first time I saw RxJS, I said: whaaaat? A lot of “weird” operators (more than 100), hot and cold observables, marble diagrams, multicast, subjects and a lot of new concepts to learn.

I suggest learning the fundamentals and try to apply reactive programming in real use cases, just like forms, user interactions or scenarios like an authentication system. Since Angular is based on Observable, it represents a great way to get closer to this world.

Anyway, I have to admit that functional reactive programming was, in my experience, one of the biggest challenges of the last few years. It is a drastic paradigm shift. So it takes a lot of time to be really appreciated and mastered.

Be patient 🙂

You mentioned in your talk that Angular Reactive Forms provide effective and scalable handling of form data. Why is that?

Reactive Forms (RF) are reusable, testable, synchronous and very flexible. In fact RFs provide access to low level APIs, that allow developers to do amazing stuff: split forms in nested groups that you can validate individually,  easily split forms in components, create forms at runtime, handle list of forms as an array and, since forms and controls (inputs, selects, calendars and so on) are treated like Observables, you can get great benefits from RxJS as well.
Furthermore, Reactive Forms are immutable, very easy to test and to debug, especially if compared to template driven forms.


How has front-end development changed with the advent of component-based frameworks, such as Angular, React and Single Page Application (SPA) pattern?

I’m a big supporter of this “pattern” but “Component-Based” frameworks are nothing new; it’s an old approach (I’ve used it since Adobe Flex, in 2008, when SPA was known as Rich Internet Applications) but it remains one of the best techniques to split and organise the application UI.

Thanks to this approach, it is very easy to create reusable code too (i.e. shared components or UiKit), test your code and avoid JS (and CSS!) conflicts. No more “globals” anymore.

But the main advantage I have seen so far is when this approach is used together with a state manager, such as Redux, in my opinion the real revolution in the SPA world of recent years.

You can now completely split the data architecture from the presentational layer, simplifying testing, enabling time travel debugging, saving and rehydrating a store, splitting the application business logic in actions, effects, reducers (to update state) and selectors (to get a portion of the store by using memorisation).


The UI (so your components) should be dumb and completely stateless, so your data model should be handled exclusively by the state manager.

This is great also because senior developers can now focus on architectural aspects while juniors and web designers can work on the UI without the fear of doing damage or “breaking” something, since it’s “stupid” and does nothing.

State managers as NGRX for Angular now combine Redux with RXJS and your data is exposed as Observable. So you can now get advantages from both worlds.

It’s amazing. ES2015/2018 and Typescript added a lot of new tools and sugar syntax as well and, finally, JS developers can write high quality code with no compromises.

Today, it’s a great time to be a front-end developer and you no longer need to be ashamed to tell the world that you use Javascript.

facebooktwitterlinkedinreddit
Share on:facebooktwitterlinkedinreddit
Interview with Elton Stoneman
Previous Post
From 0 to Kubernetes using .NET Core, Angular e Jenkins
Next Post

Related articles

  • Jamstack: Are Static Sites a New Revolution for the Web?
  • Video: A JavaScript Developers Guide to WebAssembly (with AssemblyScript)
  • How-To Guide: Improving Web Accessibility
  • Advanced CSS Tricks That You Have To Know
  • PHP for Web Development in 2022: Dead, Alive, or Missing in Action?
  • GRPC Approach for Improved Software Development
  • Pro Tips For Web Designers Who Want to Create Better Web Experiences
  • Devtools: Boosting Your Web Development Workflow on Chrome and Firefox
  • Best 10 Tools to Leverage for Progressive Web App Development
  • Getting Started with WebAssembly and Rust

Primary Sidebar

Lessons Learned in the Cloud

Dive deep into this whitepaper dedicated to the Cloud and discover more about Kubernetes.

OVH Logo Lessons learned in the cloud

Codemotion Milan 2022

https://youtu.be/ym8iilUy_U0

Latest Articles

Video: How to Use Python for Async Microservices

Microservices

AWS amplify, angular, AWS

Step by Step: Running Angular Applications in AWS

Cloud

django python framework

Top Trending Python Frameworks Today

Languages

serverless cloud

Video: Beyond Serverless Functions

Cloud

Discover More

  • Jamstack: Are Static Sites a New Revolution for the Web?
  • Why Companies Are Implementing the Developer Experience Job Position
  • Video: A JavaScript Developers Guide to WebAssembly (with AssemblyScript)

Footer

  • Magazine
  • Events
  • Community
  • Learning
  • Kids
  • How to use our platform
  • Contact us
  • Write for Us
  • About Codemotion Magazine
  • How to run a meetup
  • Tools for virtual conferences

Follow us

  • Facebook
  • Twitter
  • LinkedIn
  • Instagram
  • YouTube
  • RSS

DOWNLOAD APP

© Copyright Codemotion srl Via Marsala, 29/H, 00185 Roma P.IVA 12392791005 | Privacy policy | Terms and conditions

Follow us

  • Facebook
  • Twitter
  • LinkedIn
  • Instagram
  • RSS

DOWNLOAD APP

CONFERENCE CHECK-IN