BaseReactor

trait BaseReactor[A]

A reactor is a simple way to express an interactive program. It allows us to write programs in terms of some initial state and transformations of that state in response to inputs and clock ticks.

This is the basic interface. See Reactor for a more user friendly implementation.

It is based on * the same abstraction in Pyret.

Companion:
object
Source:
BaseReactor.scala
class Object
trait Matchable
class Any
class Reactor[A]

Value members

Abstract methods

def onMouseClick(location: Point, state: A): A
def onMouseMove(location: Point, state: A): A
def onTick(state: A): A
def render(value: A): Image
def stop(value: A): Boolean

Concrete methods

def run[Alg <: Basic, F[_], Frame, Canvas](frame: Frame)(implicit a: AnimationRenderer[Canvas], e: Renderer[Alg, Frame, Canvas], m: MouseClick[Canvas] & MouseMove[Canvas], runtime: IORuntime): Unit

Runs this reactor, drawing on the given frame, until stop indicates it should stop.

Runs this reactor, drawing on the given frame, until stop indicates it should stop.

Source:
BaseReactor.scala
def tick[F[_], Frame, Canvas](frame: Frame)(implicit e: Renderer[Basic, Frame, Canvas], runtime: IORuntime): Option[A]

Run one tick of this reactor, drawing on the given frame. Returns the next state, or None if the Reactor has stopped.

Run one tick of this reactor, drawing on the given frame. Returns the next state, or None if the Reactor has stopped.

Source:
BaseReactor.scala