zef_orchestration_core 2.0.0 copy "zef_orchestration_core: ^2.0.0" to clipboard
zef_orchestration_core: ^2.0.0 copied to clipboard

A dart library that provides a flexible and efficient way to handle and orchestrate requests using a command and query pattern.

example/zef_orchestration_core_example.dart

import 'package:zef_orchestration_core/zef_orchestration_core.dart';

class SampleCommand extends Command {}

class SampleCommandHandler extends CommandHandler<SampleCommand> {
  @override
  Future<void> call(SampleCommand command) async {
    print('Executing SampleCommand...');
    // Command execution logic here
  }
}

// Define a sample query and its handler.
class SampleQuery extends Query<String> {}

class SampleQueryHandler extends QueryHandler<SampleQuery, String> {
  @override
  Future<String> call(SampleQuery query) async {
    print('Executing SampleQuery...');
    return 'Query Result';
  }
}

void main() async {
  // Initialize the orchestrator with the simple adapter.
  OrchestratorBuilder().build();

  // Register command and query handlers.
  await Orchestrator.I.registerCommandHandler(SampleCommandHandler());
  await Orchestrator.I.registerQueryHandler(SampleQueryHandler());

  // Publish a command.
  await Orchestrator.I.publish(SampleCommand());

  // Send a query and await the result.
  final result = await Orchestrator.I.send(SampleQuery());
  print('Query returned: $result');

  // Optionally, unregister all handlers.
  await Orchestrator.I.unregisterAll();
}
2
likes
160
points
47
downloads

Publisher

verified publisherzooper.dev

Weekly Downloads

A dart library that provides a flexible and efficient way to handle and orchestrate requests using a command and query pattern.

Homepage
Repository (GitHub)
View/report issues

Topics

#orchestration #cqrs #eventing #domain-driven-design #ddd

Documentation

API reference

Funding

Consider supporting this project:

buymeacoffee.com

License

MIT (license)

More

Packages that depend on zef_orchestration_core