This is port of the reactive-core library for Scala into SuperCollider.
For more info see:
http://www.reactive-web.co.cc/core/Signal
The combinators interface is essentialy a copy of reactive-banana Haskell library.
EventSource is an instance of the Functor and Applicative Functor Type Classes.
An EventSource which fires events every time the signal changes.
f |
f: A => B |
f |
f: A => FPSignal[B] |
Implementes event switching.
Allows one, in a functional manner, to respond to an event while taking into account past events. For every event t, f is called with arguments (u, t), where u is initially the value of the 'initial' parameter, and subsequently the result of the previous application of f.
A new FPSignal that, for every event t fired by the original FPSignal, fires the result of the application of f (which will also be the next value of u passed to it). Often 'u' will be an object representing some accumulated state.
An FPSignal that sums all the integer values fired by the parent FPSignal.
switching based on the the signal itself
f |
function A -> FPSignal[ T(A, Option[B]) ] |
FPSignal[A]
Given an initial signal sigA of type FPSignal[ T(A, Option[B]) ], calling selfSwitch on it with a function f that evaluates to another signal sigB of type FPSignal[ T(A, Option[B]) ] will behave like sigA while the value of sigA is T(x, None()). When a value of type T(x,Some(v)) is received the function f is evaluated with v and sigA is switched out, sigB is switched in taking the role of sigA and repeating the procedure ad infinitum. This is a sort of recursive switching.
If this was a function it would have type
FPSignal[ T(A, Option[B]) ] -> ( A -> FPSignal[ T(A, Option[B]) ] ) -> FPSignal[A]
initVal
then we can use for convenience
which is equivalent to
Applicative functor. Apply a time-varying function to time-varying value.
es |
EventStream[A] |
EventStream[A]
When an event arrives from es, if this signal contains the true value then the event goes through.
trueES |
EventStream[A] |
falseES |
EventStream[A] |
EventStream[A]
If the current value of this signal is true then events from trueES pass through, otherwise events from falseES pass trough.
Map value with spec
nil
This FPSignal should carry values of class IO with actions to be performed. This method should be called when defining an EventNetwork with the monadic interface.
This FPSignal should carry values of class IO with actions to be performed. This method should be called when defining an EventNetwork with the monadic interface. The action which is the current value of the FPSignal will be executed when the network is compiled. This usefull for initialization.
Post incoming values to the post window with label.
Usually FPSignal child classes should be used inside an ENdef or NNdef. Nevertheless it is possible to add call-backs directly, although this is not recommended:
When the Signal changes, runs f with new value.
Run f every time a new event arrives and save the function using the name given
name |
A key |
f |
The function to call |
Unit
Stop running function f.
f |
A function |
Unit
Usually FPSignal child classes should be used inside an ENdef or NNdef. It is possible to manipulate the FRP graph directly, although this is not recommended:
Disconnects this FPSignal from the parent FPSignal (if it has a parent). If the FPSignal is not assigned to any variable anymore it will be gc'ed.
Removes all listeners. This will disconnect this EventSource from the rest of the chain that depends on it, and the rest of the chain will be gc'ed.