package com.correx.core.sessions

import com.correx.core.events.events.StoredEvent
import com.correx.core.sessions.projections.Projection

class SessionCounterProjection(
    private val sessionId: String
) : Projection<SessionCounterState> {

    override fun initial(): SessionCounterState =
        SessionCounterState(sessionId, 0)

    override fun apply(
        state: SessionCounterState,
        event: StoredEvent
    ): SessionCounterState {
        return state.copy(count = state.count + 1)
    }
}
