Package

io.dylemma

frp

Permalink

package frp

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. frp
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. sealed abstract class Event[+A] extends AnyRef

    Permalink

    Represents an event emitted by a Publisher class.

    Represents an event emitted by a Publisher class. An Event can be either a Fire or a Stop.

    A

    The type of data contained by the event.

  2. trait EventJoin[A, B, C] extends EventSource[C]

    Permalink

    An EventJoin is a transformer that takes in events of type A and B from two parent EventStreams and produces any number of new events of type C in response.

    An EventJoin is a transformer that takes in events of type A and B from two parent EventStreams and produces any number of new events of type C in response.

    To create an EventJoin, implement the three required methods:

    protected def leftParent: EventStream[A]
    protected def rightParent: EventStream[B]
    protected def handle(event: Either[Event[A], Event[B]]): Boolean

    Generally, handle will call fire and/or stop. **Note:** to see the method signatures in this documentation, make sure to select "Visibility: All".

  3. trait EventPipe[A, B] extends EventSource[B]

    Permalink

    An EventPipe is a transformer that takes in events of type A from a single parent EventStream and produces any number of new events of type B in response.

    An EventPipe is a transformer that takes in events of type A from a single parent EventStream and produces any number of new events of type B in response.

    To create an EventPipe, implement the two required methods:

    protected def parent: EventStream[A]
    protected def handle(event: Event[A]): Boolean

    Generally, handle will call fire and/or stop. **Note** to see the method signatures in this documentation, make sure to select "Visibility: All".

  4. trait EventSource[A] extends EventStream[A] with EventSourceImpl[A]

    Permalink

    EventSource is an implementation of EventStream that adds fire and stop methods.

    EventSource is an implementation of EventStream that adds fire and stop methods. Usage in client code will generally look something like

    class CoolThings {
    	private val _events = EventSource[Thing]
    
    	// don't expose `fire` and `stop` publicly: EventStream is read-only
    	def events: EventStream[Thing] = _events
    
    	def doThings = { events fire new Thing(...) }
    }
  5. trait EventStream[+A] extends AnyRef

    Permalink

    An EventStream represents a (potentially finite) series of events that may occur at any time in the future.

    An EventStream represents a (potentially finite) series of events that may occur at any time in the future. EventStreams are stylistic replacements for Publishers (from the Publisher/Subscriber, or Observer pattern). Events are produced as Event instances - either a Fire or Stop. Each Fire event produced by an EventStream represents a single "data". The Stop event represents the end of the stream. Once an EventStream produces a Stop event, it is considered finished and will produce no more events.

    There are several ways to attach event handlers to an EventStream. The most low-level way is to use the sink method, which operates on Event instances. The foreach method is used to attach a handler that operates only on data from Fire events. onNext and onEnd attach handlers to the next Fire and a Stop, respectively. Attaching event handlers requires an implicit Observer, which is used to manage references between the handler and the stream.

    EventStreams can be transformed and combined in a variety of ways like filtering, mapping, and concatenation.

    Below is a working example of EventStream usage.

    class Example extends App with Observer {
    	// Create an EventStream instance. EventSource is a subtype of
    	// EventStream, with the addition of `fire` and `stop` methods.
    	val stream = EventSource[Int]
    
    	// Create a mapped version of the EventStream
    	val mappedStream = stream.map(_ * 2)
    
    	// Attach an event handler, using the `foreach` syntax
    	for(i <- stream) println("Int event: " + i)
    	for(i <- mappedStream) println("Mapped event: " + i)
    
    	// Attach an "end" event handler
    	stream onEnd { println("Got the end") }
    
    	// fire some events
    	stream fire 1
    	// (prints "Int event: 1")
    	// (prints "Mapped event: 2")
    
    	stream fire 5
    	// (prints "Int event: 5")
    	// (prints "Mapped event: 10")
    
    	// stop the stream
    	stream.stop
    	// (prints "Got the end")
    }
  6. implicit class EventStreamFutures[A] extends AnyRef

    Permalink
  7. case class Fire[A](event: A) extends Event[A] with Product with Serializable

    Permalink

    Represents a single item from a stream of events.

    Represents a single item from a stream of events.

    A

    the type of the item in the event

    event

    the item in the event

  8. trait Observer extends AnyRef

    Permalink

    A memory management assistant.

    A memory management assistant. The expected usage is that an Observer instance will be the only thing that holds strong references to some collection of objects; once the Observer instance is no longer strongly-reachable (can be garbage collected), then neither will the collection of objects that it references.

    An implicit Observer is required when interacting with Sources, to facilitate "automatic" memory management. To create an Observer, either explicitly do so:

    implicit object myObserver extends Observer

    or mix one into the containing class:

    class Worker extends Observer {
        //do things that require an implicit Observer
    }
  9. trait Time[T] extends AnyRef

    Permalink

    Typeclass for types that can get the current time.

    Typeclass for types that can get the current time. EventStream methods that generate a time stamp of type T will require an implicitly-available instance of Time[T]. A default implementation is available as SystemTime, which simply returns the result of System.currentTimeMillis.

    T

    The type of the time.

Value Members

  1. object EventSource

    Permalink
  2. object EventStream

    Permalink
  3. object Stop extends Event[Nothing] with Product with Serializable

    Permalink

    Represents the end of a stream of events.

  4. implicit object SystemTime extends Time[Long]

    Permalink

    An instance of the Time typeclass, for Long times.

    An instance of the Time typeclass, for Long times. The currentTime will always return the result of System.currentTimeMillis.

Inherited from AnyRef

Inherited from Any

Ungrouped