All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.nextgentel.oss.akkatools.aggregate.GeneralAggregateView.scala Maven / Gradle / Ivy

There is a newer version: 2.5.0.2
Show newest version
package no.nextgentel.oss.akkatools.aggregate

import no.nextgentel.oss.akkatools.persistence.{EnhancedPersistentView, GetState}

import scala.reflect.ClassTag

class GeneralAggregateView[E:ClassTag, S <: AggregateStateBase[E, S]:ClassTag]
(
  persistenceIdBase:String,
  id:String,
  initialState:S,
  collectHistory:Boolean = true
) extends EnhancedPersistentView[E, S](persistenceIdBase, id, collectHistory) {

  var state:S = initialState

  override def currentState():S = state

  override def applyEventToState(event: E): Unit = {
    state = state.transitionState(event).newState
  }

  override val onCmd: PartialFunction[AnyRef, Unit] = {
    case x:GetState =>
      sender ! state
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy