Effective State Management in Angular Applications

Discover techniques for managing application state effectively using services and store patterns to enhance data flow and organization.

0 likes
45 views

Rule Content

{
  "title": "Effective State Management in Angular Applications",
  "description": "Discover techniques for managing application state effectively using services and store patterns to enhance data flow and organization.",
  "category": "Angular Cursor Rules",
  "rules": [
    {
      "pattern": "import { BehaviorSubject } from 'rxjs';",
      "message": "Consider using Angular's built-in Signals for state management to leverage native reactivity and reduce external dependencies.",
      "severity": "warning"
    },
    {
      "pattern": "import { Store } from '@ngrx/store';",
      "message": "Evaluate if Angular's Signal Store can meet your state management needs, offering a more integrated and streamlined approach.",
      "severity": "info"
    },
    {
      "pattern": "export class (\\w+)Service \\{",
      "message": "Ensure that services managing state adhere to the Single Responsibility Principle, focusing solely on state management logic.",
      "severity": "warning"
    },
    {
      "pattern": "this\\.store\\.dispatch\\(",
      "message": "When dispatching actions, confirm that they are well-defined and align with the application's state management strategy.",
      "severity": "info"
    },
    {
      "pattern": "this\\.state\\.next\\(",
      "message": "Directly mutating state can lead to unpredictable behavior; consider using immutable patterns or state management libraries.",
      "severity": "error"
    }
  ]
}