Angular πŸ‡ΊπŸ‡¦ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
This media is not supported in your browser
VIEW IN TELEGRAM
πŸ“„ Angular Signals: untracked function

#angular #signals #untrackted

untracked allows reading the value of a signal without making such signal a dependency of our computed signal or effect.

In this example, increasing the counter doesn’t trigger a new computation of info. Only a new name does so


name = signal('Angular');
counter = signal(0);

info = computed(
() =>
`The name is now "${this.name()}" and the
counter value was ${untracked(this.counter)} when
the name changed.`
);


🚩 > Angular 17

βœ… Article link
πŸ‘4
πŸ€“ Implementing Two-Way Data Binding

#angular #signals #model

🚩 > Angular 17

βœ… Article link
πŸ“„ How to Replace RxJS with Signals

#angular #rxjs #signals

βœ… Article link
πŸ‘2
🩷 Difference Between Compute and Effect in Angular Signals

#angular #signals #computed #effect

Computed Signals: Derived Signal

Function: Computed signals represent values derived from other signals. Think of them as formulas that take existing signals as inputs and produce a new output value.
Creation: You define them using the computed function, specifying a derivation function that outlines how the computed value is calculated.
Benefits:
Lazy Evaluation: Computed signals are calculated only when their value is needed. This avoids unnecessary computations.
Memoization: Subsequent reads of the computed signal with the same dependencies return the cached value, improving performance.
Dependency Tracking: Angular automatically tracks which signals a computed signal depends on. When any of those signals change, the computed signal is automatically recalculated.

Effects: Actions Triggered by Signal Changes

Function: Effects are functions that execute in response to changes in signals. They typically perform side effects like logging, interacting with external APIs, or updating local storage.
Creation: You create effects using the effect function. This function can optionally accept a onCleanup function for managing long-running operations.
Benefits:
Reactivity: Effects automatically run whenever their dependent signals change, ensuring your application stays up-to-date.
Asynchronous Execution: Effects run asynchronously during change detection, preventing them from blocking the main thread.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
❀1
🩷 How to avoid subjects and middle services between different components

#angular #signals #inject #guide

On the first screen, we have a ParentComponent that passes data to a ChildComponent, which in turn passes the data to an InnerChildComponent. This is a simple example.

On the second screen, the example will help you to remove prop drilling from your Angular applications and make your code more maintainable and easier to understand.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ–€πŸ©· Angular: Initialize SignalStore from Resolver

#angular #signals #resolver

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘1
🌐 Signals communication between components

#angular #signals #guide

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
🌐 Dynamic Render Component in A18

#angular #signals #input #dynamic #ngComponentOutlet

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
🌐 πŸ’˜ Lightweight NGRX signalStore with Angular. Complete guide

#angular #signals #signalStore #guide

What is NGRX signalStore?
NgRx SignalStore is a fully-featured state management solution that offers a robust way to manage application state. With its native support for Signals, it provides the ability to define stores in a clear and declarative manner. The simplicity and flexibility of SignalStore, coupled with its opinionated and extensible design, establish it as a versatile solution for effective state management in Angular.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
❀1πŸ‘1
🩷 How to rewrite component inputs to signals correctly

#angular #signals

βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
🩢 Media query matcher in Angular with RxJS, signals and NgClass

#angular #signals #service #matchMedia

To achieve the desired outcome, I’ve opted for an approach that follows this pattern:

β€” Create a service with a `mediaQuery()` method, which returns an RxJS Observable containing information on whether a specific breakpoint is matched or not.

β€” Create a property inside the component class (in the example we will call it `isMobile`, since we have only one breakpoint) and bind it the the `mediaQuery()` method previously crafted, but also converting the Observable to a signal.

β€” Utilize the `NgClass` directive to dynamically apply a class based on the value of the `isMobile` property.


βœ… Article Link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘1
πŸ€“ From RxJS to Signals

#angular #rxjs #signals

βœ… Article Link
πŸ‘7
🩷 Stop Using BehaviorSubject in Every Angular Service

#angular #signals

BehaviorSubject Is a Loaded Gun

It holds state, pushes values, and is hot by default. That means:

β€” Every new subscriber instantly gets the last value
β€” You must manually manage .next() calls
β€” It often leads to imperative logic (e.g. if (...) this._value$.next(...))
β€” And worst of all?

It gives you a stream, but not semantics.

You can’t know if the value is:

β€” Cached
β€” Live from server
β€” Derived from another value
β€” Meant to be read-only


βœ… Article Link
Please open Telegram to view this post
VIEW IN TELEGRAM
2πŸ‘7❀1