The easier way to code Angular apps

preview_player
Показать описание

Ever hear about "declarative" coding or "reactive" coding? These are concepts I struggled to properly understand and appreciate for a long time. This video aims to give a brief explanation that gets right to the heart of what this is all about and why it is beneficial.

0:00 Introduction
1:38 What is declarative?
3:57 Why observables?
4:24 This is still imperative
6:06 Declarative version
7:54 The benefit
8:23 Imperative is not bad

#ionic #angular

Рекомендации по теме
Комментарии
Автор

I appreciate a lot this explanation. Finding variables through the code is always a mess for me. But I dont understand the last code example. The buyItem method is empty and said that is managed by observable... But how? Can someone give me some hint? Thanks

davidechierici
Автор

Observables and RxJS operators are a game changer.

That being said, RxJS is also a powerful foot-gun and it is easy to get yourself into a situation where your declarative pipes are every bit as convoluted and even harder to debug than straightforward imperative code. This is especially true when combining observables.

pchasco
Автор

I think the key reason you should work declaratively as much as possible is that your main goal with any component should be to minimize state as much as possible. That means as few writable or mutable public properties as humanly possible within your component. This holds true for any component based web framework.

jasonrooney
Автор

Recently, I'm just get into learning how to code reactively and I found your videos super useful. Thank you for all your videos and hope that there will be more about this topic

luongtd
Автор

You are so great at explaining challenging topics and have really improved your presentation style. When I first saw your videos I was a bit overwhelmed by your focus on ionic, but even then you still had really good Angular content. I see you've recently done a lot more Angular and the quality of your videos is even better now so really excited to see more videos from you. I think you will reach 1 million subscribers. You are special.

BGivo
Автор

Every time I watch your videos I learn something new. Thanks for the awesome content!

IagoCCampos
Автор

I found this video incredibly useful. 6 months after switching to Angular from React I am not declarative 100% but I end up always subscribe to observablels as a part of my brain still tells me that I need to "own" those state values by storing them in variables. The example you are showing here is a lot smoother and shows me I still have along way to go and adjust to this mindset. I would like to become a pro member on your platform but for the moment I am not interested in Ionic but purely on Angular. I was wondering if you have more courses going to be added on that..! Not judging, I think that what you are doing is great is just that I am not into mobile apps rn

LowrollerWTF
Автор

One of the most valuable videos on the internet, simple and fabulous, more people should know these techniques.

martinemanuel
Автор

As someone who also uses more the declarative approach, I like the video. One suggestion though, when using a ternary operator, you don't need " ? true : false" since the left side of the ? operator (condition) already returns a boolean, right? That's the point of a ternary operator. So we can just use and return that value. In this case at 6:10 it would be:
map(itemsLeftInStock => itemsLeftInStock > 0)
I always get triggered by this, when seeing it in the PRs, since it's redundant.

mysterion_e
Автор

Very nicely explained. The key idea is that a simple variable represents a single value, but a stream represents all of the values at once

mykolakozachenko
Автор

I love the way how you explain things, it is pretty close to me, I can't stop watching 😍

VV-kvcc
Автор

oh Man You just inspired me to make few awesome changes in my code to make it better! This is fantastic!

KolosBros
Автор

This video is probably the best to explain declarative. I was struggling to explain declarative to new people 😅

disableblue
Автор

Great post, and right on time (for me).

abstractobject
Автор

Nice. Never heard about the concept, but always intuitively aimed for that.

The data flow must be crystal clear in Angular.

martinkrutzfeld
Автор

Fantastic explanation
I've just started using Angular and RxJS and I knew right from the start that I was missing something. This coding style looks unnatural at first, but now I'm starting to understand it's benefits.

jnk_
Автор

I have been down this road myself. One thing I would like to add is that part of the power of this library comes in the form of functional programing. Although the Observer pattern is more flashy because makes it "reactive" it is only one part of the equation the other is in reality functional programming with all the great things it has like pure functions and thus avoiding side effects and of curse like you mention a few times :) makes the code declarative rather than imperative. The declarative part comes from functinal programming and not from Observer pattern.

bmiguelmf
Автор

I want more videos like this for common and more complex use cases

theanswer
Автор

Nice. Signals simplifies the declarative approach even further starting in v16

justinwmusic
Автор

I'm a big fan of your content, Josh. G'day from Mooloolaba, QLD 👍

MattBodman