UndoableVar

semagrams.util.UndoableVar
class UndoableVar[A](init: A) extends SignalSource[A] with Sink[A]

A class similar to Var but with support for undo and redo.

Attributes

Graph
Supertypes
trait Sink[A]
trait SignalSource[A]
trait Source[A]
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def now(): A

Get the current state

Get the current state

Attributes

def record(): Unit

Turn on recording; updates now save previous state in undo history

Turn on recording; updates now save previous state in undo history

Attributes

def redo(): Unit

Undo the last undo

Undo the last undo

Attributes

def save(): Unit

Manually save current state in undo history

Manually save current state in undo history

Attributes

def set(a: A): Unit

Set the current state in an undo-aware manner

Set the current state in an undo-aware manner

Attributes

def toObservable: Signal[A]

Coerce to the signal

Coerce to the signal

Attributes

def toObserver: Observer[A]

Coerce to the writer

Coerce to the writer

Attributes

def undo(): Unit

Undo the last update

Undo the last update

Attributes

def unrecord(): Unit

Turn off recording; updates now do not save previous state

Turn off recording; updates now do not save previous state

Attributes

def update(f: A => A): Unit

Similar to update for Vars, but undo-aware

Similar to update for Vars, but undo-aware

Attributes

def updateS[B](s: State[A, B]): IO[B]

Use the state monad to update the Var, and returns the result asynchronously after the Var is updated.

Use the state monad to update the Var, and returns the result asynchronously after the Var is updated.

Note: IO continues before the Transaction ends; is this bad? The reason we want to use a Transaction is so that we don't lose updates to the state in between reading it out and updating it, and we need to return after that Transaction fires asynchronously; this is the only way I know how to do that. If we see weird bugs around this then we can rethink how this works.

Attributes

def updateS_[B](s: State[A, B]): IO[Unit]

Use a state monad to update the Var; doesn't return the result.

Use a state monad to update the Var; doesn't return the result.

Wraps in IO for convenience.

Attributes

def updater[B](f: (A, B) => A): Observer[B]

Similar to updater for Vars, but undo-aware

Similar to updater for Vars, but undo-aware

Attributes

def zoomL[B](l: Lens[A, B]): LensedVar[A, B]

Construct a derived variable using l; see LensedVar

Construct a derived variable using l; see LensedVar

Attributes

Concrete fields

val signal: Signal[A]

A signal of the current value

A signal of the current value

Attributes

val writer: Observer[A]

An observer that wraps UndoState.update to record (or not) updates depending on whether recording is set in the state

An observer that wraps UndoState.update to record (or not) updates depending on whether recording is set in the state

Attributes