japgolly.webapputil.indexeddb

Type members

Classlikes

final class IndexedDb(raw: IDBFactory)
Companion:
object
object IndexedDb
Companion:
class
final class IndexedDbKey extends AnyVal
Companion:
object
Companion:
class
final case class KeyCodec[A](encode: A => IndexedDbKey, decode: IndexedDbKey => CallbackTo[A])
Companion:
object
object KeyCodec
Companion:
class
sealed trait ObjectStoreDef[K, V]
Companion:
object
Companion:
class
final case class Txn[+M <: TxnMode, +A](step: TxnStep[M, A])

Embedded language for safely working with(in) an IndexedDB transaction.

Embedded language for safely working with(in) an IndexedDB transaction.

This is necessary because whilst all the transaction methods are async, any other type of asynchronicity is not supported and will result in IndexedDB automatically committing and closing the transaction, in which case, further interaction with the transaction will result in a runtime error.

Therefore, returning AsyncCallback from within transactions is dangerous because it allows composition of both kinds of asynchronicity. To avoid this, we use this embedded language and don't publicly expose its interpretation/translation to AsyncCallback. From the call-site's point of view, a Txn[A] is completely opaque.

This also has a nice side-effect of ensuring that transaction completion is always awaited because we do it in the transaction functions right after interpretation. Otherwise, the call-sites would always need to remember to do it if live transaction access were exposed.

Type parameters:
A

The return type.

Companion:
object
object Txn
Companion:
class
sealed abstract class TxnDsl[M <: TxnMode]
Companion:
object
object TxnDsl
Companion:
class
sealed trait TxnMode
Companion:
object
object TxnMode
Companion:
class
sealed trait TxnStep[+M <: TxnMode, +A]

Embedded language for safely working with(in) an IndexedDB transaction.

Embedded language for safely working with(in) an IndexedDB transaction.

This is necessary because whilst all the transaction methods are async, any other type of asynchronicity is not supported and will result in IndexedDB automatically committing and closing the transaction, in which case, further interaction with the transaction will result in a runtime error.

Therefore, returning AsyncCallback from within transactions is dangerous because it allows composition of both kinds of asynchronicity. To avoid this, we use this embedded language and don't publicly expose its interpretation/translation to AsyncCallback. From the call-site's point of view, a Txn[A] is completely opaque.

This also has a nice side-effect of ensuring that transaction completion is always awaited because we do it in the transaction functions right after interpretation. Otherwise, the call-sites would always need to remember to do it if live transaction access were exposed.

Type parameters:
A

The return type.

Companion:
object
object TxnStep
Companion:
class
final case class ValueCodec[A](encode: A => CallbackTo[IDBValue], decode: IDBValue => CallbackTo[A])
Companion:
object
object ValueCodec
Companion:
class

Types

type TxnDslRO = RO.type
type TxnDslRW = RW.type

Value members

Concrete methods

@inline
@inline