api_command_queue_bloc 0.2.0
api_command_queue_bloc: ^0.2.0 copied to clipboard
Bloc and hydrated_bloc adapters for the api_command_queue core package.
api_command_queue_bloc #
api_command_queue_bloc provides Cubit and HydratedCubit adapters for the pure Dart api_command_queue core package.
It is intended for applications that want to:
- mirror a core queue or orchestrator as a bloc state stream
- persist queue state with
hydrated_bloc - keep domain queue logic in the core package while using bloc-based app wiring
Which Package? #
- Use
api_command_queuewhen you want framework-agnostic queueing primitives. - Use
api_command_queue_blocwhen your app already usesbloc/hydrated_blocand you want queue state exposed as cubits.
Install #
dependencies:
api_command_queue: ^0.1.0
api_command_queue_bloc: ^0.1.0
Example #
import 'package:api_command_queue/api_command_queue.dart';
import 'package:api_command_queue_bloc/api_command_queue_bloc.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
HydratedBloc.storage = MyStorage();
final queue = ExampleQueue();
final hydrated = HydratedApiCommandQueueCubit(
queue: queue,
storagePrefix: 'ExampleQueue',
storageId: 'primary',
);
await hydrated.flush();
await hydrated.close();
See example/main.dart for a runnable example.
Hydration Identity #
HydratedApiCommandQueueCubit follows hydrated_bloc storage-token semantics:
storagePrefixis the persistence namespacestorageIdis the per-instance discriminator- the final key is
storagePrefix + storageId
For existing apps migrating from a previously hydrated queue class, keep storagePrefix aligned with the old queue runtime type or previous storage namespace so persisted queue state continues to restore correctly.
Typical Setup #
The adapter package does not replace the core queue logic. A typical arrangement is:
- Define commands and queues in
api_command_queue. - Wrap long-lived queues with
HydratedApiCommandQueueCubitwhen you want persistence. - Wrap the core orchestrator with
ApiCommandOrchestratorCubitwhen the rest of the app expects bloc state.
The core queue remains the source of truth for queue behavior. The cubit wrappers mirror state and lifecycle.