Figuring out which code goes where is one of the bigger challenges when building an application. And now that Angular suggests storing our variable values in signals, it's important to consider where we declare those signals.
In this video, we answer a key question: Should we declare our signals in our services or in our components?
*Links*
Code: https://stackblitz.com/~/edit/sia-service-with-signals-deborahk
YouTube video: "Signals in Action: Building an App":
https://youtu.be/LHgJP7MwTWY
YouTube video: "Providing a Service in root vs Component":
https://youtu.be/K01oDsWRCEQ
YouTube video: "First Look at Angular's new resource() and rxResource()":
https://youtu.be/_KyCmpMlVTc
*Content*
00:00 Where should we declare our signals?
00:27 Service with signals
01:40 Share data
02:14 Retain data when a component is destroyed
03:01 Provide parameters for the HTTP request
03:19 Retain retrieved data
03:59 Film Service
05:08 Cart Feature
07:04 Signals in a Component
07:45 Signals in a Service vs a Component
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
😊About Me
Hey! I'm Deborah Kurata
I'm a software developer and YouTube content creator. I speak at conferences such as VSLive and ng-conf. I write articles for freeCodeCamp. And I'm a Pluralsight author with courses in the top 10 most popular (out of 7,000+) for over 5 years. For my work in support of software developers, I've been recognized with the Microsoft Most Valuable Professional (MVP) award, and I'm a Google Developer Expert (GDE).
View my YouTube content: https://www.youtube.com/@deborah_kurata
Contact me on Twitter: @DeborahKurata
Or on Bluesky: @deborahkurata.bsky.social
Find my Pluralsight courses: https://www.pluralsight.com/profile/author/deborah-kurata
Access my freeCodeCamp articles: https://www.freecodecamp.org/news/author/deborah-kurata/
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
#angular
#angularsignals
#angularsignalstutorial
#angularstatemanagementwithsignals
#angularstatemanagement
#angulartutorials
#angularforbeginners
#angularbestpractices
#signalsinangular
#signalsfordatasharing
#signaltutorial
#resource
#rxresource