BaseAccess

korolev.Context$.BaseAccess
trait BaseAccess[F[_], S, M]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Access[F, S, M]
class MappedAccess[F, S1, SN, E]

Members list

Concise view

Value members

Abstract methods

def downloadFileAsStream(handler: FileHandler): F[Stream[F, Bytes]]

Download file from the client side by file handler

Download file from the client side by file handler

Attributes

def downloadFiles(id: ElementId): F[List[(FileHandler, Bytes)]]

Download the selected file list from input appropriate to given element id. Use this method carefully because all files are saving to RAM.

Download the selected file list from input appropriate to given element id. Use this method carefully because all files are saving to RAM.

Attributes

def downloadFilesAsStream(id: ElementId): F[List[(FileHandler, Stream[F, Bytes])]]

Same as downloadFiles but for stream mode. The method is useful when user want to upload very large files list which is problematic to keep in memory (especially when count of users is more than one).

Same as downloadFiles but for stream mode. The method is useful when user want to upload very large files list which is problematic to keep in memory (especially when count of users is more than one).

Attributes

def downloadFormData(id: ElementId): F[FormData]

Downloads form from the client. Useful when when you want to read big amount of fields. Do not use this method for downloading files, however it is possible.

Downloads form from the client. Useful when when you want to read big amount of fields. Do not use this method for downloading files, however it is possible.

event(submit) { access =>
 access
   .downloadFormData(myForm)
   .flatMap { formData =>
     val picture = data.file("picture") // Array[Byte]
     val title = data.text("title") // String
     access.transition {
       // ... transtion
     }
   }
}

Attributes

id

form elementId

def evalJs(code: JsCode): F[String]

Execute arbitrary JavaScript code on client and get stringified JSON back.

Execute arbitrary JavaScript code on client and get stringified JSON back.

for {
 _ <- access.evalJs("new Date().getTimezoneOffset()").map(offset => ...)
 _ <- access.evalJs(js"$myForm.submit()").map(offset => ...)
} yield ()

Attributes

def focus(id: ElementId): F[Unit]

Makes focus on the element

Makes focus on the element

Attributes

def imap[S2](lens: Lens[S, S2]): Access[F, S2, M]
def listFiles(id: ElementId): F[List[FileHandler]]

Get only file list for input

Get only file list for input

Attributes

Extracts property of element from client-side DOM.

Extracts property of element from client-side DOM.

Attributes

See also:
Since:

0.6.0

Example:
event('click) { access =>
 for {
   request <- access.property(searchField).get('value)
   result  <- searchModel.search(request)
   _       <- access.transition {
     case state: State.Awesome =>
       state.copy(list = searchResult)
   }
 } yield ()
}
def publish(message: M): F[Unit]

Publish message to environment.

Publish message to environment.

Attributes

def registerCallback(name: String)(f: String => F[Unit]): F[Unit]

Register callback that could be invoked from the client side.

Register callback that could be invoked from the client side.

 // Scala
 access.registerCallback("myCallback") { myArg =>
   Future(println(myArg))
 }

 // JavaScript
 Korolev.invokeCallback('myCallback', 'myArgValue');

Attributes

def resetForm(id: ElementId): F[Unit]

Purge inputs in given form.

Purge inputs in given form.

Attributes

id

form element id binding

def sessionId: F[Qsid]

Gives current session id.

Gives current session id.

Attributes

def state: F[S]

Gives current state.

Gives current state.

Attributes

def stateFocus[B](lens: Lens[S, B]): F[B]
def transition(f: () => S): F[Unit]

Applies transition to current state.

Applies transition to current state.

Attributes

def transition[B](lens: Lens[S, B])(f: () => B): F[Unit]
def transitionAsync(f: F => S): F[Unit]

Applies asynchronous transition to current state. All transitions will wait until this transition will executed.

Applies asynchronous transition to current state. All transitions will wait until this transition will executed.

NOTE: Do not use this method id you work with effects which take lot of time for execution. It's may lead to hanging of your app.

Attributes

def transitionAsync[B](lens: Lens[S, B])(f: F => B): F[Unit]
def transitionForce(f: () => S): F[Unit]

Applies transition to current state and awaits render.

Applies transition to current state and awaits render.

Attributes

def transitionForce[B](lens: Lens[S, B])(f: () => B): F[Unit]
def transitionForceAsync(f: F => S): F[Unit]

Attributes

See also:
def transitionForceAsync[B](lens: Lens[S, B])(f: F => B): F[Unit]
def uploadFile(name: String, stream: Stream[F, Bytes], size: Option[Long], mimeType: String): F[Unit]

Upload stream to the client side with selected name, size and mimeType

Upload stream to the client side with selected name, size and mimeType

Attributes

Concrete methods

def evalJs(code: String): F[String]
def imap[S2](map: PartialFunction[S, S2], contramap: PartialFunction[(S, S2), S]): Access[F, S2, M]
final def maybeTransition(f: PartialFunction[S, S]): F[Unit]

Applies transition to current state.

Applies transition to current state.

Attributes

final def property(id: ElementId, propName: String): F[String]

Shortcut for property(id).get(propName).

Shortcut for property(id).get(propName).

Attributes

Since:

0.13.0

final def valueOf(id: ElementId): F[String]

Shortcut for property(id).get('value).

Shortcut for property(id).get('value).

Attributes

Since:

0.6.0

Deprecated methods

final def property(id: ElementId, propName: Symbol): F[String]

Shortcut for property(id).get(propName).

Shortcut for property(id).get(propName).

Attributes

Since:

0.6.0

Deprecated
true
def syncTransition(f: () => S): F[Unit]

Attributes

Deprecated
[Since version 1.5.0]