Comments (6)
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.
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.
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.
Great! will take a look a it!
from opencqrs.
Thanks @andreujuanc
from opencqrs.
Breaking changes here: https://github.com/OpenCQRS/OpenCQRS/releases
from opencqrs.
Related Issues (20)
- [Question] About CommandSequence exception handling HOT 3
- Saga Pattern HOT 8
- InvalidOperationException: Unable to resolve service for type HOT 13
- Approximate Date for Snapshot support? HOT 1
- Support for tenant store HOT 1
- Support for custom discriminator in EF Stores HOT 1
- [Question] How can I setup the cosmos db context to use containers with shared throughtput option HOT 2
- How can I setup an ExecutionStrategy with Cosmos EF
- [Question] Is it possible to customize partition key on cosmos store? HOT 1
- Microservices example HOT 1
- Kledex 2.5.1 - Event handlers get called twice HOT 2
- About load Events HOT 5
- Decorate an event handler HOT 3
- Bulk capabilities HOT 3
- [Question] What is the process to contribute? HOT 3
- Following wiki, always getting 'Some services are not able to be constructed HOT 4
- Application templates HOT 8
- [Question] Is there any plan to use Microsoft.Azure.Cosmos ? HOT 2
- Custom handler or service HOT 1
- Kledex adds "everything" to the ServiceCollection twice, or more. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencqrs.