-
Notifications
You must be signed in to change notification settings - Fork 4
Projections
Generally spoken, projections are some sort of container for event handlers of the published events from the domain server.
Same as for models, they also live in two environments. On the one hand, there are the standard projections on the projection server, which update their specific projection model and on the other hand, there is the domain projection. The domain projection cares about updating the domain model.
Codewise they are pretty similar, ecxept for their includings. Standard projections should include the ActiveProjection::ProjectionType
module and the domain projection should include ActiveDomain::Projection
.
The public methods of the projections should be named exact like the underscore notation of the event they handle. For example take a PostCreateEvent
, then the code should be:
def post_create_event(event)
#do stuff with the event, like "Post.create!"
end
The directories for the projections are app/projections
and domain/projections
.