A visual guide to changing without reassigning in DECLARATIVE code

  Рет қаралды 8,446

Joshua Morony

Joshua Morony

Күн бұрын

Пікірлер: 30
@JoshuaMorony
@JoshuaMorony 3 ай бұрын
Someone on reddit pointed out that the placement of the catchError would mean it only handles the first error, I've fixed this up in the source code but just be aware of that in the code shown in the video
@JosimarBezerra-fx8wb
@JosimarBezerra-fx8wb 20 күн бұрын
This is the kind of explanation on declarative code that I've been looking for. Before I came across this video, I'd already understood enough to be able to work with this declarative approach but, I still wasn't 100% sure of how to properly picture the situation in my head for the problems I'd been trying to solve at that point. Thanks to you, now that's not a problem anymore. I've been a huge fan of your work. Keep it up!
@RasmusChristensen-n5j
@RasmusChristensen-n5j 3 ай бұрын
It is really nice with the visualizations. It helps a lot when looking at the side-by-side with the code :) Keep it up Joshua, you are doing good work.
@PandaPlaysAll
@PandaPlaysAll 3 ай бұрын
What program do you use to animate
@JoshuaMorony
@JoshuaMorony 3 ай бұрын
@@PandaPlaysAll I'm using Motion Canvas
@iriel492ki
@iriel492ki 3 ай бұрын
One of your best videos to date. Excellent!
@SoheilMohammadi-v6b
@SoheilMohammadi-v6b 3 ай бұрын
this graph was so helpfull, I'v been trying declarative paradigm for some time, and it cleared up a lot of stuff for me that I was struggling with
@magodelviento
@magodelviento 2 ай бұрын
Vey nice man, well explained.
@souravsaraf1230
@souravsaraf1230 3 ай бұрын
Really loved the declarative approach as always. Can you please show a sample implmentation of this with Signals without using Rxjs ?
@JoshuaMorony
@JoshuaMorony 3 ай бұрын
Signals (Angular signals specifically) only is possible only until you need to handle anything async (like the http request in this example). The basic idea with signals is that you just use computed to derive anything that is dependent on some other thing. Then at the top of your graph you might have a standard writable signal that you can imperatively set to trigger everything else below reacting to it. Once you need to deal with async stuff though you will need to bring in RxJS or something else if you want to keep it declarative (derivedFrom from ngxtension is an option, which allows you to do async stuff with signals with the RxJS stuff hidden behind the scenes)
@mortezatourani7772
@mortezatourani7772 3 ай бұрын
Most of the time, a change in filters resets the page so I assume we can move it above the page so it also manage that
@TheMightRoux
@TheMightRoux 2 ай бұрын
Can someone tell me what the materialize()/dematerialize() operators do? first time i've seen these :O
@CaptainQ2607
@CaptainQ2607 26 күн бұрын
Gave away your Australianess with Vegemite XD Hi from NZ
@BrettCoffin
@BrettCoffin 3 ай бұрын
Bravo !!! and thank you ;)
@dmitriylazarenko3220
@dmitriylazarenko3220 3 ай бұрын
Great video as usual! I’m a big fan of your channel. I looked at the GitHub code and correct me if I’m wrong but it looks like if there be let’s say a connection error with the back end that error will not be handled because in your error handling you rely on the fact that back end returns something
@JoshuaMorony
@JoshuaMorony 3 ай бұрын
This should work with any kind of error on the observable stream, though you will have to modify it to more appropriately handle different types of errors - this example just naively prints out whatever the 'error' property of the notification is (but with an http error that is going to be an object)
@JZubero
@JZubero 3 ай бұрын
Do you have an take on how to avoid reassigning when you want to subscribe to an event-style observable (e.g. ionInput of ion-searchbar) of a component that is being fetched as ViewChild (in angular)? Is there a way to work around the fact that the ViewChild/CMP reference will be undefined in the constructor scope?
@JoshuaMorony
@JoshuaMorony 3 ай бұрын
@@JZubero yes I'm not at my computer now so can't grab the exact link, but I have a video titled something like "refactoring my ugliest code" which is about how signal view queries make this much easier, but I also show how I did it pre-signals
@JZubero
@JZubero 3 ай бұрын
@@JoshuaMorony Spot on! Exactly what I was looking for. thx ✌
@cocoscacao6102
@cocoscacao6102 3 ай бұрын
what do you use to animate stuff?
@JoshuaMorony
@JoshuaMorony 3 ай бұрын
I'm using motioncanvas.io
@Rexyness
@Rexyness 3 ай бұрын
Correct me if I'm wrong , but with the approach of combineLatest([page,filter]) the page will not reset (to the first page) when filter emits.
@antoxa5315
@antoxa5315 3 ай бұрын
I think If we change switchMap to switchScan we can handle filter value change and reset current page index
@aaronhauth8880
@aaronhauth8880 3 ай бұрын
I think that's intended behavior for this graph. Otherwise, the graph would be more linear (filter => page => request => data). The example is illustrating that either of those things will kick off an http request, that will return with updated data.
@JoshuaMorony
@JoshuaMorony 3 ай бұрын
Yes you're correct and yes I think it's sensible here to reset the page to 1 when the filter changes. Without getting into different types of approaches, the easiest approach for this example is probably just to next the page BehaviorSubject with 1 as an imperative side effect of the filter changing. Since we are using switchMap and Angular's HttpClient here we don't really need to worry about our combineLatest stream emitting multiple times
@iukys3889
@iukys3889 Ай бұрын
You could also use merge(page, filter.pipe(map(() => 1) instead of just page since you want to reset the page each time filter emits
@jaybee6382
@jaybee6382 3 ай бұрын
In essence, create a new state from an old state, rather than mutating the old state into a new state.
@donmorris4506
@donmorris4506 3 ай бұрын
Vegemite, noooooo🤢
How to deeply understand Angular signals (...or anything)
10:51
Joshua Morony
Рет қаралды 1,4 М.
A visual guide to switchMap and "higher order" observables
7:46
Joshua Morony
Рет қаралды 9 М.
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 32 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 17 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 63 МЛН
Why I decided to switch to the inject() function in Angular
6:10
Joshua Morony
Рет қаралды 61 М.
The easier way to code Angular apps
9:54
Joshua Morony
Рет қаралды 69 М.
Angular change detection explained in 5 minutes
6:06
Simplified Courses
Рет қаралды 15 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 837 М.
How To Build Feature Flags Like A Senior Dev In 20 Minutes
20:33
Web Dev Simplified
Рет қаралды 101 М.
Angular Resource API - Everything You Have To Know (so far)
27:58
Decoded Frontend
Рет қаралды 14 М.
Why you should care about DECLARATIVE programming
9:14
Joshua Morony
Рет қаралды 18 М.
I only ever use *these* RxJS operators to code reactively
25:25
Joshua Morony
Рет қаралды 135 М.
All Rust features explained
21:30
Let's Get Rusty
Рет қаралды 324 М.
Here's what I've figured out about Angular signals
8:33
Joshua Morony
Рет қаралды 22 М.