noma_chat_advanced library
Advanced / opt-in surface for noma_chat.
Out-of-the-box use cases only need the primary barrel:
import 'package:noma_chat/noma_chat.dart';
The advanced barrel exposes the lower-level knobs that 90% of apps never touch:
- Auth interceptors for custom token/cookie/header flows beyond
the built-in bearer / basic auth that
NomaChat.createwires for you. - Cache tuning (CacheConfig,
MemoryLocalDatasource) for apps that need to override TTLs, eviction policy, or replace the default Hive store with an in-memory one (tests, demos). - Retry tuning (RetryConfig) for custom backoff strategies.
- Resilience primitives (
computeBackoffMs, CircuitBreaker, CircuitBreakerRegistry) for apps that talk to the same backend outside the bundled HTTP client (e.g. a REST call the SDK doesn't wrap yet) and want the same jittered backoff and per-path circuit breaking the SDK already applies internally, instead of reimplementing a weaker version of it.
Use this barrel only when you need it. Importing it pulls in
types that are intentionally low-level and may evolve faster than
the primary API. The primary barrel re-exports anything that
appears in public method signatures (CachePolicy,
ChatLocalDatasource, HiveAesCipher) so you rarely need both.
Example — wiring a custom retry config:
import 'package:noma_chat/noma_chat.dart';
import 'package:noma_chat/noma_chat_advanced.dart';
final chat = await NomaChat.create(
baseUrl: '...',
realtimeUrl: '...',
currentUser: ChatUser(id: '...', displayName: '...'),
tokenProvider: () async => '...',
retryConfig: const RetryConfig(maxAttempts: 5),
cacheConfig: const CacheConfig(
ttlMessages: Duration(minutes: 30),
),
);
Classes
- AuthInterceptor
- Base class for authentication interceptors that inject auth headers into HTTP requests.
- BasicAuthInterceptor
- HTTP Basic authentication using a fixed username and password.
- BearerAuthInterceptor
- Bearer token authentication with automatic refresh on 401 responses.
- CacheConfig
- Configuration for the SDK's caching layer.
- CircuitBreaker
- CircuitBreakerRegistry
- MemoryChatLocalDatasource
-
In-memory implementation of ChatLocalDatasource. Data is lost when
the process exits. The
ChatResultwrap returnsChatSuccessfor every operation — no I/O means nothing to fail on. - RetryConfig
- Configuration for automatic HTTP request retries with exponential backoff.
Enums
Functions
Typedefs
-
MetricCallback
= void Function(String metric, Map<
String, dynamic> data)