NgRx Advanced
Entity adapter, feature states, meta-reducers, router store, component store, effects patterns, error handling
1What is the main role of createEntityAdapter in NgRx?
What is the main role of createEntityAdapter in NgRx?
Answer
The Entity Adapter automatically generates reducers and selectors to manage normalized collections of entities. It provides methods like addOne, addMany, updateOne, removeOne that facilitate manipulation of ID-indexed objects. This avoids manually writing collection management logic and ensures a normalized state for better performance.
2What data structure does Entity Adapter use to store entities?
What data structure does Entity Adapter use to store entities?
Answer
Entity Adapter stores entities in an object with two properties: ids (ordered array of identifiers) and entities (key-value dictionary for O(1) access). This normalized structure avoids duplicates, facilitates updates by ID and optimizes lookup performance. The ids array maintains display order.
3How to specify a custom sort comparator with Entity Adapter?
How to specify a custom sort comparator with Entity Adapter?
Answer
The sort comparator is defined via the sortComparer property when creating the adapter. This function compares two entities and returns a number (negative, zero or positive) to determine their order. If sortComparer is set to false, no automatic sorting is applied and ids maintain insertion or update order.
Which Entity Adapter method to use to add or update multiple entities in a single operation?
Which predefined Entity Adapter selector retrieves all entities as an array?
+21 interview questions
Other Angular interview topics
TypeScript Basics
TypeScript Advanced
Angular Fundamentals
Components & Lifecycle
Services & Dependency Injection
Angular Modules Organization
Angular CLI
Directives & Pipes
Routing & Navigation
Reactive Forms
Template-driven Forms
RxJS Fundamentals
RxJS Operators
HttpClient & API Calls
Basic State Management
Change Detection
Angular Signals
Standalone Components
Angular Unit Testing
End-to-End Testing
Build & Optimization
NgRx Fundamentals
Angular Architecture
Performance Optimization
Security & Best Practices
Advanced RxJS Patterns
Angular Universal & SSR
Angular Micro-frontends
Master Angular for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free