💥 Angular Signal Inputs (COMING SOON in Angular 17.1)

Поділитися
Вставка
  • Опубліковано 26 лип 2024
  • In this video we are going to cover a new feature in the upcoming Angular 17.1 release: Angular Signal Inputs.
    We will see how signal inputs are an alternative to the traditional @Input decorator, and we will demo how they provide an alternative to the OnChanges lifecycle hook.
    Related short form videos:
    Angular Signal Inputs In 60 seconds - • 💥 Angular Signal Input...
    Related articles on the Angular University blog:
    Angular Signals: Complete Guide -blog.angular-university.io/an...
    Timestamps:
    0:00 Intro
    0:40 Coverting @Input to Signal Inputs
    5:23 replacing OnChanges with effect()
    08:00 required, alias and transform options
    Free content at the Angular University:
    - 20% of our lessons are free, you don't have to login to watch the lessons. The free lessons are the ones with the P (Pro) - angular-university.io
    - Watch the free Angular For Beginners Course - angular-university.io/course/...
    Follow me:
    Twitter - / angularuniv
    Facebook - / angular.university
    UA-cam - / @angularuniversity
    Instagram - / angular.university
    LinkedIn - / angular-university
    TikTok - / angularuniversity
    Threads - www.threads.net/@angular.univ...

КОМЕНТАРІ • 70

  • @AngularUniversity
    @AngularUniversity  6 місяців тому +2

    To learn in detail Angular Signals, check out the Angular Core Deep Dive Course - angular-university.io/course/angular-course👍

  • @Nabulio85
    @Nabulio85 4 місяці тому +1

    I've been following you since I started programming in 2019.
    Thank you Vasco.

    • @AngularUniversity
      @AngularUniversity  4 місяці тому

      You're welcome, I'm happy to hear that 😊 I'll keep the videos coming 😉

  • @user-nn3sd1st5p
    @user-nn3sd1st5p 6 місяців тому +8

    I totally recommend Angular University. Very good quality of learning material! Both the blog and the video courses.

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +1

      Thank you, it's awesome to hear that 😊 Please enjoy the courses 👍

  • @user-nw1db9ms3t
    @user-nw1db9ms3t 6 місяців тому +2

    Excellent content, Greetings from COLOMBIA!!

  • @AlainBoudard
    @AlainBoudard 6 місяців тому +2

    Thanks for sharing Vasco ! Always good Angular content !

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +1

      My pleasure Alain, thanks for watching and please enjoy the new content. 👍😊

  • @malikau917
    @malikau917 6 місяців тому +1

    Since now you will be my main resource of angular news! :)

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      Thank you, stay tuned for more coverage of the Angular ecoystem 😊

  • @Yobo77
    @Yobo77 5 місяців тому

    Great content as always!

  • @Brendan2Alexander
    @Brendan2Alexander 5 місяців тому

    I have been with angular since angular2 was in alpha. Can’t state enough how awesome signals is. Thank u Angular team! Great video.

    • @AngularUniversity
      @AngularUniversity  5 місяців тому

      Yes the same for me, it's an awesome framework😊

  • @sivuyilemagutywa5286
    @sivuyilemagutywa5286 6 місяців тому +4

    This is way easy now, I always hated doing Geters and Seters,

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +2

      I like it too, it's way better this way 🙂. For getters and setters, there are now input transforms that replace most of the use cases.

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 6 місяців тому +2

      NgOnChanges even worse, hate that sh.. signals are soooooo nice

  • @LarsRyeJeppesen
    @LarsRyeJeppesen 6 місяців тому +1

    Signal inputs are soooo cool

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      I love them too, makes the whole signal approach much more appealing. Looking forward to application wide reactivity. 😉

  • @Michel000000001
    @Michel000000001 6 місяців тому +2

    I really enjoy your content! So clear, and also just a bit more indepth so I don't get stuck on building the first real feature for myself.
    If you like this content: this expert also has a great site where you can get a subscription on all his content for a moderate fee, and a course on Udemy, which is packed with info and updated to the latest versions; this Udemy course is almost for free. Lots of thank you from the Netherlands 🙏

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +1

      Thank you Michel, please enjoy the channel and the courses. 😊

  • @flanderstruck3751
    @flanderstruck3751 6 місяців тому +1

    Thank you very much! Very well presented :-)

  • @besara_
    @besara_ 6 місяців тому +2

    greate vedio as usual

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      Thank you, it's awesome to hear that. 😊 Please enjoy the channel. 👍

  • @DisturbedNeo
    @DisturbedNeo 6 місяців тому +1

    That transform option is crazy. You can map data with a reusable transformation function on a per-component basis that updates automatically whenever new data comes in, directly in the input signal. Insane.

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      I love the new transform option too, it replaces the need for getters and setters and certain uses of ngOnChanges, very nice. It's also available for the regular @Input decorator. 👍

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 6 місяців тому

      Just don't abuse it

  • @zetalivsanns5360
    @zetalivsanns5360 6 місяців тому +2

    Thanks professor 🫡

  • @omarabdelhameed1066
    @omarabdelhameed1066 6 місяців тому +1

    Great video ❤

  • @yufgyug3735
    @yufgyug3735 6 місяців тому +1

    i like the direction angular is taking with these signals, new template syntax etc. the only problem in quick adoption of newer angular versions is sketchy update cycle of packages my projects depend on.

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +1

      The Angular CLI makes is super easy to upgrade between versions, and you have this website to help also with upgrade notes - update.angular.io 👍

  • @seekthetruth5458
    @seekthetruth5458 6 місяців тому +2

    Great video and explanations! What if a signal comes from a service to a grand parent component then is passed to a parent and then to a child? Do input signals work with the nested trees of components and preserve their reactivity on every level?

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +2

      Thank you 😊 If the signal is passed around through components via a service, all consumers of the signal will be notified of new values. Check out the video on Signal-based data services here on the channel. 👍

  • @seekthetruth5458
    @seekthetruth5458 6 місяців тому +1

    Also it pretty much looks like Angular is leaning towards React and Vue's concepts of reactivity. So similiar and easy to use compared to RxJS.

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +2

      Yes there is a convergence, and with the upcoming functional authoring format that seems to be in the works it will be even more so. RxJs will become optional and outside the main learning path. Angular is really taking off. 🚀😊

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 6 місяців тому +2

      React doesn't use Signals afair. React also does not have local detection (sections of a component); which Angular will have very soon

    • @seekthetruth5458
      @seekthetruth5458 6 місяців тому

      @@LarsRyeJeppesen that's true - no signals in React, but they have useState hook that operates like signals.

  • @Dmooney777
    @Dmooney777 5 місяців тому +1

    Can you do two-way binding with input signals?

    • @AngularUniversity
      @AngularUniversity  5 місяців тому

      There is no two-way binding with signals, you need to invoke the signal with () as a function to get a value, and you need to call set or update on it to modify the value.

  • @fernandoh.7965
    @fernandoh.7965 6 місяців тому +3

    I think I have a problem when I use input.required, in my unit tests
    in my console it shows error code NG0950

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      weird, this could be an issue, remember this is still in RC0

  • @francescoguagnano1212
    @francescoguagnano1212 6 місяців тому +1

    Hi, how to use features like changes.value.firstChange or changes.value.previousValue in the new effect function?

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      Signals only emit the last value. I think for that specific use case you could use the RxJs interoperability. 👍

  • @besara_
    @besara_ 6 місяців тому +1

    i hope webstorm consider this update from now, not like 17 update

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      Me too, with a bit of luck they are on top of it. I like Webstorm a lot.

  • @MukeshRathore86
    @MukeshRathore86 6 місяців тому +2

    Have we covered course on micro-frontend using angular? I am asked to work on it in my organization.

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +2

      We didn't cover micro-frontends so far on the channel, that is something that I could look into. I think with Angular, it would be a matter of giving each frontend a separate build, and they could share a common shared module.

    • @MukeshRathore86
      @MukeshRathore86 6 місяців тому +1

      @@AngularUniversity The challenge we are facing right now is when there are multiple team working on different github repository and we need to have communication between those unrelated components after deployed on server.

  • @ansumanmishra9608
    @ansumanmishra9608 6 місяців тому +1

    What are the advantages of signal based inputs?

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      These are reactive inputs, the main advantage is that it makes it super simple to implement your components in reactive style using signals.

    • @DisturbedNeo
      @DisturbedNeo 6 місяців тому

      It means that when a value changes, only the components using that value will re-render. With input signals, you could theoretically write an entire Angular application with Zone.js disabled, and you'll never have to learn about change detection strategies.

  • @paulh6933
    @paulh6933 6 місяців тому +2

    is there any word whether it will be experimental or production?

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      I didn't see it mentioned anywhere yet. I think they will put in developer preview first, as they usually do.👍

    • @DisturbedNeo
      @DisturbedNeo 6 місяців тому

      Yeah, my guess is it'll be marked as experimental in 17.1, and made stable in 18.0

  • @francescoguagnano1212
    @francescoguagnano1212 6 місяців тому +1

    Hi, what about performance since signals are functions and in the template it’s being binding a function to get signal value and since in Angular it’s better to avoid function binding to not have performance issues?

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +1

      It's not a problem at all. When full signal-based reactivity is available, and everything is plugged into change detection, it will be faster this way.😁

    • @francescoguagnano1212
      @francescoguagnano1212 6 місяців тому +1

      Mmm however I created a small project with a standalone component and with change detection onpush and in the template I put in binding a signal in a paragraph and a button that at the click increments a counter in a very normal variable that has nothing to do with the signals (I only did it to be able to trigger the click event) and then I debugged the signals.mjs file of angular/core precisely in the getter function contained in the createSignal function and my fear was confirmed because despite having an onpush component, the getter function of the signal is called clicking on the button that does not update anything , so they did not really solve the problem of the functions in binding.

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +1

      @@francescoguagnano1212 Mostly signals are not yet plugged in with change detection. they are not plugged into normal change detection, and with OnPush they are only integrated in very particular scenarios. Signals right now provide a nice alternative to Rjxs for writing reactive shared data services, but the change detection benefits are not here right now; Signals are a work in progress. 👍

  • @USONOFAV
    @USONOFAV 6 місяців тому +1

    would input signal display the value on the console without effect block? Like, just put console.log(${this.value()}) ?

    • @AngularUniversity
      @AngularUniversity  6 місяців тому

      You mean if you log on the constructor? It would only do that once, it wouldn't call again console.log. The effect is needed for the logging statement to be called again with each new value of the input, as a side effect.

    • @AlainBoudard
      @AlainBoudard 6 місяців тому

      Yes, Signals are not streams like RxJs Observables so you need to plug into effect or computed callback.

  • @Dajuhf
    @Dajuhf 6 місяців тому +1

    effect isn't just to log things and not indicated to use to code inside it?

    • @AngularUniversity
      @AngularUniversity  6 місяців тому +1

      Effect is not just meant for logging, that is just an example of a typical side-effect. You can use effects for any typical side effect, liek writing to local storage, writing to the database in the background, writing to a cookie, logging, etc. If you want to calculate derived data, use the computed API instead. 👍

  • @trimalakismeno
    @trimalakismeno 5 місяців тому

    My biggest problem with this is that i can't be initializing all my objects for the inputs every time. But if i don't, then angular will make the signal , and then i have to have a gazillion checks that the value of the signal is not undefined before i do something, otherwise typescript always complains. Is there a workaround or better way of doing this?

    • @AngularUniversity
      @AngularUniversity  5 місяців тому +1

      You can use input.required instead, and make the field mandatory. You can also give the signal an explict type, to avoid the | undefined.

    • @trimalakismeno
      @trimalakismeno 5 місяців тому

      @@AngularUniversity even if i give it an explicit type e.g. user = input.required() angular initializes this with 'User | undefined'. I guess the input.required is a better solution. But if I misunderstood your solution please let me know bcs I'd like to get around this