Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.westyx.cloud/llms.txt

Use this file to discover all available pages before exploring further.

Installation

.npmrc
@westyx-nexus:registry=https://gitlab.com/api/v4/projects/<PROJECT_ID>/packages/npm/
npm install @westyx-nexus/sdk-angular
Requires Angular 17+ and TypeScript 5.4+. No token needed - the registry is public.

Setup

import { ApplicationConfig } from '@angular/core';
import { provideNexus } from '@westyx-nexus/sdk-angular';

export const appConfig: ApplicationConfig = {
  providers: [
    provideNexus({
      baseUrl: 'https://your-service.nexus.westyx.dev',
      apiKey:  'pk_live_...',
    }),
  ],
};
The SDK uses APP_INITIALIZER to block rendering until the initial sync completes - components always see a populated cache.

Reading values in a component

import { Component } from '@angular/core';
import { injectNexus } from '@westyx-nexus/sdk-angular';

@Component({
  standalone: true,
  template: `
    <div>API base: {{ apiBase }}</div>
    <div *ngIf="newUI">New UI enabled!</div>
  `,
})
export class MyComponent {
  private nexus = injectNexus();

  apiBase = this.nexus.getConfig('API_BASE_URL') ?? '';
  newUI   = this.nexus.getFlag('new-ui', false);
}

API

MethodReturnsDescription
getConfig(key)string | undefinedConfig value
getConfigAs<T>(key)T | undefinedTyped config
getFlag(key, default)booleanFlag value; default if not found
evaluateAB(keys, userId, attrs)Observable<Record<string,boolean>>A/B evaluation
Frontend (pk_live_) services cannot access secrets. Calling getSecret on an Angular app is a compile-time error - the method does not exist on the browser SDK interface.

SSE live updates

The SDK opens an SSE stream automatically after the initial sync. Value changes propagate within milliseconds and trigger Angular’s change detection via NgZone. The stream uses a 429-aware pre-flight fetch probe before opening EventSource, with exponential backoff (1→30 s) and a 3-strike circuit breaker.

Stream observer hooks

provideNexus({
  baseUrl: '...',
  apiKey:  '...',
  observer: {
    onConnected:        () => console.log('stream connected'),
    onFallback:         (reason) => console.warn('fallback:', reason),
    onReconnectAttempt: (n, err) => console.warn(`reconnect #${n}`, err),
  },
})