Mediatr: [Question] sharing common data in a pipeline

Created on 23 May 2018  路  2Comments  路  Source: jbogard/MediatR

As per the title says, it is possible to share data between behaviors within a pipeline?

Most helpful comment

The pipeline can be injected into, so you just create a class that is registered as per request scope, this class is brought through the constructor. On that class you can store data for the next behaviour (that sort of acts like a http context).

All 2 comments

The only way to "share" data in a pipeline is through the requests/responses themselves. For those two, you can get creative. I didn't want to introduce a "context" parameter to pass through, however.

The pipeline can be injected into, so you just create a class that is registered as per request scope, this class is brought through the constructor. On that class you can store data for the next behaviour (that sort of acts like a http context).

Was this page helpful?
0 / 5 - 0 ratings