BaseAccess

trait BaseAccess[F[_], S, M]
class Object
trait Matchable
class Any
trait Access[F, S, M]
class MappedAccess[F, S1, SN, E]

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

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.

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).

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
     }
   }
}
Value parameters:
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 ()
def focus(id: ElementId): F[Unit]

Makes focus on the element

Makes focus on the element

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

Extracts property of element from client-side DOM.

Extracts property of element from client-side DOM.

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.

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');
def resetForm(id: ElementId): F[Unit]

Purge inputs in given form.

Purge inputs in given form.

Value parameters:
id

form element id binding

def sessionId: F[Qsid]

Gives current session id.

Gives current session id.

def state: F[S]

Gives current state.

Gives current state.

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.

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.

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.

def transitionForce[B](lens: Lens[S, B])(f: () => B): F[Unit]
def transitionForceAsync(f: F => S): F[Unit]
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

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.

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

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

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

Since:

0.13.0

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

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

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

Since:

0.6.0

Deprecated methods

@deprecated("Use \"propertyName\" instead of \'propertyName", "0.13.0")
final def property(id: ElementId, propName: Symbol): F[String]

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

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

Since:

0.6.0

Deprecated
@deprecated("Use transitionForce instead", since = "1.5.0")
def syncTransition(f: () => S): F[Unit]
Deprecated
[Since version 1.5.0]