Git Product home page Git Product logo

Comments (6)

andreujuanc avatar andreujuanc commented on July 27, 2024

Got something working!

To test the demo:

  • Clone my repo change to branch simplifyDispatcher.
  • Breakpoint on CommandSender Line 41.
  • Run in Debug mode OpenCqrs.Examples.Web.EF.SqlServer example project.

Important part:
https://github.com/andreujuanc/OpenCQRS/blob/simplifyDispatcher/src/OpenCqrs/Commands/CommandSender.cs#L41

There, or somewhere else is where the library should decide on its on what to execute.

So it can have the data that before was passed trough generics, now it's set in the actual command, like so:

 public class CreateProduct : DomainCommand<Product>
 {
        public string Title { get; set; }
 }

With handler like this:

  public class CreateProductHandler : ICommandHandlerWithDomainEventsAsyncWOOT<CreateProduct>
  {
      public async Task<IEnumerable<IDomainEvent>> HandleAsync(CreateProduct command)
      {
          await Task.CompletedTask;
          var product = new Product(command.AggregateRootId, command.Title);
          return product.Events;
      }
  }

This way the command changes from this:

await dispatcher.SendAndPublishAsync<CreateProduct, Product>(new CreateProduct());
To this:
await dispatcher.SendAsyncWOOT(new CreateProduct());

REMARKS:

  • I have not tested performance or any issue related to this implementation.
  • Probably all the type generation can be cached efficiently.
  • This introduces breaking changes, might be a good thing for v6?

from opencqrs.

lucabriguglia avatar lucabriguglia commented on July 27, 2024

I like the idea of making commands responsible of the aggregate root definition and I would like to do the same for queries/results.
I'm not so sure about the implementation in the command sender tough, I'll give it a try in the next few days.

from opencqrs.

lucabriguglia avatar lucabriguglia commented on July 27, 2024

Based on your suggestion I'm adding a new global option and a property to the ICommand interface in order to publish or not the event. You can follow the progress on the dev branch: https://github.com/OpenCQRS/OpenCQRS/tree/Dev

from opencqrs.

andreujuanc avatar andreujuanc commented on July 27, 2024

Great! will take a look a it!

from opencqrs.

lucabriguglia avatar lucabriguglia commented on July 27, 2024

Thanks @andreujuanc

from opencqrs.

lucabriguglia avatar lucabriguglia commented on July 27, 2024

Breaking changes here: https://github.com/OpenCQRS/OpenCQRS/releases

from opencqrs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.