Subscription: The act of "listening to" an observable. When you subscribe, you provide handlers for: next value, error, and completion. Don't forget to unsubscribe to avoid memory leaks. A subscription connects your code to an Observable. When you subscribe, you provide handlers for new values, errors and completion, and the stream starts delivering.
Many streams never complete on their own, such as clicks, timers or WebSocket messages. Their subscriptions keep running until you unsubscribe, even after the component that created them is gone.
What should you keep in mind with Subscription?
Forgotten subscriptions are a classic source of memory leaks and of strange behaviour, such as an API being called twice because an old component still listens. Unsubscribe when a component is destroyed, or use helpers that do it for you, such as Angular's async pipe or the takeUntil pattern in RxJS. In Vue and React, the same applies to event listeners and intervals set up in effects or lifecycle hooks.
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.
Implement Command Query Responsibility Segregation for scalable architectures. Use when separating read and write models, optimizing query performance, or building event-sourced systems.