@dangerouslyRemoveOn
@dangerouslyRemoveOn
complements the @removeOn
directive.
There are cases where you might want your projection to react to events from multiple topics.
In such cases, you can use the @dangerouslyRemoveOn
directive to remove data from the projection based on events from multiple topics.
Possible Inconsistencies
Using @dangerouslyRemoveOn
can lead to inconsistencies in your projection.
The order of events is only guaranteed within a single topic, not across multiple topics.
Therefore it might happen that all events of topic A are applied before all events of topic B, even if the event from topic B was published before the event from topic A.
If this is not a problem for your projection, you can use @dangerouslyRemoveOn
to remove data from the projection based on events from multiple topics.
Example
If you want to react to actions in several topics, you can't just use the @removeOn
directive. You have to use the @dangerouslyRemoveOn
directive.
In the following case the removeUser
event will remove data identified by the value of its id
payload field from the projection.
type User
@removeOn(
on: {
topic: "userManagement"
eventTypes: ["removeUser"]
}
identifyBy: { payload: ["id"] }
)
@dangerouslyRemoveOn(
on: {
topic: "roleManagement"
eventTypes: ["removeUser"]
}
identifyBy: { payload: ["userId"] }
) {
// ...
}
As you can see in this example, the removeUser
events from two different topics are used to remove data from the projection.
For more information, please see the removeOn directive.