Skip to content
raix (Reactive And Interactive eXtensions) is a functional, composable, API for AS3 that simplifies working with data, regardless of whether its interactive (arrays) or reactive (events). raix was previously RxAs
ActionScript C# JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
asdoc/templates
build
documentation/marblediagrams Added average implementation with tests Jun 4, 2010
prooftests
source
tools/marble/source/RxAs.MarbleDiagramGenerator
.gitignore
EDULINQ-LICENSE.txt
LICENSE Added chain, mergeMany, concatMany. Removed queue and changed urlLoad… May 15, 2011
README.md
build.properties
build.xml
user.properties.eg Updated user.properties.eg to flex the Flex 3/4 combo Jul 22, 2010

README.md

Reactive And Interactive eXtensions (raix) is a functional, composable, API for AS3 that simplifies working with data, regardless of whether its interactive (arrays) or reactive (events).

raix.reactive

raix.reactive brings a more familiar API pattern to asynchronous data, like events. The center of raix.reactive is IObservable, which can be created by using one of the Observable static methods or by using the global toObservable function. It can then by subscribed to by calling subscribe and passing in a function to call when it receives a value. You can also provide a function to call when the sequence completes or when an error occurs.

Let's look at a quick example:

var doubleClicks : IObservable = Observable.fromEvent(stage, MouseEvent.CLICK)
    .timeInterval()
    .filter(function(ti:TimeInterval):Boolean { return ti.interval < 300; })
    .removeTimeInterval();

var subscription : ICancelable = doubleClicks.subscribe(function(me:MouseEvent):void
{
    trace("Double click");
});

// Unsubscribe (removing all event listeners)
subscription.cancel();

The above code accomplishes quite a bit, including managing event subscriptions and that state requires to determine the time difference between events, in a very small amount of code.

IObservable has many operators for filtering and merging asynchronous data streams, but also includes even more operators that relate to time. Check out the Reactive Operators reference or the raix.reactive livedocs

Getting Started

More

raix.interactive

raix.interactive abstracts away data structures like arrays and focuses on a forward-only "stream" of values. The center of raix.interactive is IEnumerable, which can be created using one of the Enumerable static methods or by using the global toEnumerable function. It can then be enumerating by using the built in for each keyword in actionscript.

Let's look at a quick example:

var filteredAndMapped : IEnumerable = toEnumerable([1, 2, 3, 4, 5, 6, 7, 8, 9])
    .filter(function(i:int):Boolean { return (i % 2) == 0); })
    .map(function(i:int):String { return "It's value " + i; });

for each(var value : String in filteredAndMapped)
{
    trace(value);
}

// Output:
// It's value 2
// It's value 4
// It's value 6
// It's value 8

Enumerable sequences have common operations like map and reduce, but can also be combined with other sequences through join or zip. Have a look at the Interactive Operations reference or the raix.interactive livedocs.

You can’t perform that action at this time.