Access

korolev.Context$.Access
trait Access[F[_], S, M] extends BaseAccess[F, S, M] with EventAccess[F, S, M]

Provides access to make side effects

Attributes

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

Members list

Concise view

Value members

Inherited 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

Inherited from:
BaseAccess
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

Inherited from:
BaseAccess
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

Inherited from:
BaseAccess
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

Inherited from:
BaseAccess
def evalJs(code: String): F[String]

Attributes

Inherited from:
BaseAccess
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

Inherited from:
BaseAccess
def eventData: F[String]

Gives json with string, number and boolean fields of object of the event happened in current render phase. Note that is expensive operation which requires network round trip.

Gives json with string, number and boolean fields of object of the event happened in current render phase. Note that is expensive operation which requires network round trip.

Attributes

Inherited from:
EventAccess
def focus(id: ElementId): F[Unit]

Makes focus on the element

Makes focus on the element

Attributes

Inherited from:
BaseAccess
def imap[S2](map: PartialFunction[S, S2], contramap: PartialFunction[(S, S2), S]): Access[F, S2, M]

Attributes

Inherited from:
BaseAccess
def imap[S2](lens: Lens[S, S2]): Access[F, S2, M]

Attributes

Inherited from:
BaseAccess
def listFiles(id: ElementId): F[List[FileHandler]]

Get only file list for input

Get only file list for input

Attributes

Inherited from:
BaseAccess
final def maybeTransition(f: PartialFunction[S, S]): F[Unit]

Applies transition to current state.

Applies transition to current state.

Attributes

Inherited from:
BaseAccess
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

Inherited from:
BaseAccess

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 ()
}
Inherited from:
BaseAccess
def publish(message: M): F[Unit]

Publish message to environment.

Publish message to environment.

Attributes

Inherited from:
BaseAccess
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

Inherited from:
BaseAccess
def resetForm(id: ElementId): F[Unit]

Purge inputs in given form.

Purge inputs in given form.

Attributes

id

form element id binding

Inherited from:
BaseAccess
def sessionId: F[Qsid]

Gives current session id.

Gives current session id.

Attributes

Inherited from:
BaseAccess
def state: F[S]

Gives current state.

Gives current state.

Attributes

Inherited from:
BaseAccess
def stateFocus[B](lens: Lens[S, B]): F[B]

Attributes

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

Attributes

Inherited from:
BaseAccess
def transition(f: () => S): F[Unit]

Applies transition to current state.

Applies transition to current state.

Attributes

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

Attributes

Inherited from:
BaseAccess
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

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

Attributes

Inherited from:
BaseAccess
def transitionForce(f: () => S): F[Unit]

Applies transition to current state and awaits render.

Applies transition to current state and awaits render.

Attributes

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

Attributes

Inherited from:
BaseAccess
def transitionForceAsync(f: F => S): F[Unit]

Attributes

See also:
Inherited from:
BaseAccess
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

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

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

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

Attributes

Since:

0.6.0

Inherited from:
BaseAccess

Deprecated and Inherited 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
Inherited from:
BaseAccess
def syncTransition(f: () => S): F[Unit]

Attributes

Deprecated
[Since version 1.5.0]
Inherited from:
BaseAccess