Lesson Description
The "SignalStore Q&A" Lesson is part of the full, Advanced Angular: Performance & Enterprise State course featured in this preview video. Here's what you'd learn in this lesson:
Alex explains SignalStore’s command-based approach, compares it to the global store, highlights extended APIs, and shows how stores can interact for scalable state management.
Transcript from the "SignalStore Q&A" Lesson
[00:00:00]
>> Alex Okrushko: Is the NgRx global store now deprecated in favor of Signal Store? Great question. So, neither global store nor component store are deprecated. We do recommend starting with Signal Store today. If you're using global store, it's still going to work. It's not going to go, it's the most popular state management library now, more for historic reasons. That state management library is only event-based.
[00:00:33]
Signal Store right now we're looking at as command-based, right? We can add call the add book, which is if we're just telling it specifically what to do. It still uses the interaction, we tell it what to do one way and we'll listen for reactive property again, similar to how we had it with the count, right, for tickets. So, but yeah, the answer to that question is no, none of them is going to go away.
[00:01:03]
There's no reason to go away, they are supported, there's not a lot of changes in them. But they're supported and they're not going to go anywhere. Both actually global store and component store had extended the APIs to return signals instead of observables as well, with select signal. So if you have the global store and you want to have something more signal-based, it's literally just instead of select, it's select signal, very easy to work with.
[00:01:35]
But yeah, they're supported, not going to go anywhere. So the Signal Store is, like you said, command-based, so you're not going to see actions being dispatched anywhere in the future. I'm glad you asked, well, because it's so extensible, one of the custom features that we have is event plugin. So you can have a command-based, event-based, a mixture of the two, whatever floats your boat, right?
[00:02:06]
Command-based is easier, event-based is for those who really understand events and have more complex interactions. Those are really great, it's like multi-level abstraction, like two-level abstractions. They're great. We're not going to cover events today, but yes, there's a lot of really cool stuff, and I'm going to show you how to really use it nicely today. I think we're getting into with, not with hooks, but I'm also trying to map between global and NgRx and this.
[00:02:39]
So where do effects and the effects, yes, effects will be our methods. So with methods, we can have special ones, and that will be where we'll be running sort of effects as well. So if you're mapping from the global store, with state is your reducers, they're controlling the state. With computed is your selectors, and with methods would be responsible for asynchronous things, like effects to interact effects, not the signal effects.
[00:03:21]
Can one store access another store? Beautiful question, yes, and this is where a really scalable architecture becomes important. I wanted to talk about it at the end, but since the question came up now, you can typically have signal stores that are provided in route, and they are the ones who are responsible for like here, book state, or we'll have some ticket state or event state, right? And they don't really care how that state is consumed, and then you can have signal stores that are provided at lower levels, like tabs or event details that might have their own signal store that can inject the parent one from the global scope and pull the data or even ask it to push something, but then it would have more of a component business logic inside of them.
[00:04:23]
That's where the scalability of this architecture really becomes a good point. Yes, good question. I will show you how to inject things into the signal store once we start implementing.
Learn Straight from the Experts Who Shape the Modern Web
- 250+In-depth Courses
- Industry Leading Experts
- 24Learning Paths
- Live Interactive Workshops