Skip to main content

State Management

LocalStorage

The application uses browser localStorage for state persistence:

Stored Data:

  • jwt - JWT authentication token
  • agentID - Current user/agent ID
  • role - User roles (JSON array)
  • username - Username
  • Other session-specific data

Observable Pattern (RxJS)

Services use RxJS Observables for reactive data flow:

// Example from ApiService
return this.http.post<any>(OSAS_API + '/auth/signin', payload, { headers });

Components subscribe to Observables:

this.apiService.getUser(username, password).subscribe(
  response => { /* handle response */ },
  error => { /* handle error */ }
);

Service State

Services maintain application state:

  • Singleton services (providedIn: 'root')
  • State shared across components
  • Data caching where appropriate