StateLoader

class Object
trait Matchable
class Any

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.

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

State is same for all sessions.

State is same for all sessions.

Type parameters:
S

Type of state

Value parameters:
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, ...)
 }
}