Atomic Angular — Doc interne

Principal store

The signed-in user's data, loaded once and shared through a signal store — initials, admin status, and user-override state.

PrincipalStore holds the authenticated user's data — name, email, administrator status, password expiry — loaded once via initialize() and shared by every consumer through NgRx Signals.

Minimal example

Reading the signed-in user's name and initials
user-badge.component.ts
import { Component, inject } from "@angular/core";
import { PrincipalStore } from "@sinequa/atomic-angular";

@Component({
  selector: "user-badge",
  template: `<span>{{ principal.fullName() }} ({{ principal.initials() }})</span>`,
})
export class UserBadgeComponent {
  protected readonly principal = inject(PrincipalStore);
}

How it works

initialize() fetches the principal through the shared client (so it goes through the same auth handling as the rest of @sinequa/atomic — cookies included, and the SSO-aware auto-authentication flag) and patches the store. Concurrent calls — a guard awaiting the fetch while another initialization is already in flight — share the same promise rather than issuing two requests.

yes no ok error initialize() a fetch already in flight? return the same promise patchState: loading client.api.principal.get() patchState: loaded, principal fields set patchState: error, rethrow

Options

Prop

Type

Pitfalls

What's next

On this page