StateLoader

korolev.server.StateLoader$

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Value members

Concrete methods

def apply[F[_], S](f: (DeviceId, Head) => F[S]): F => S

State depends on deviceId and HTTP-request. Second one could be None if case when user reconnected to restarted application and state wasn't restored.

State depends on deviceId and HTTP-request. Second one could be None if case when user reconnected to restarted application and state wasn't restored.

Attributes

def default[F[_] : Effect, S](initialState: S): F => S

State is same for all sessions.

State is same for all sessions.

Attributes

S

Type of state

initialState

State factory

def forDeviceId[F[_], S](initialState: DeviceId => F[S]): F => S

State depends on deviceId. Useful when you want to restore user authorization.

State depends on deviceId. Useful when you want to restore user authorization.

case class MyState(deviceId: DeviceId, ...)

StateLoader.forDeviceId { deviceId =>
 MyStorage.getStateByDeviceId(deviceId) map {
   case Some(state) => state
   case None => MyState(deviceId, ...)
 }
}

Attributes