Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/richardszalay/raix
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
https://github.com/richardszalay/raix
Last synced: 26 days ago
JSON representation
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
- Host: GitHub
- URL: https://github.com/richardszalay/raix
- Owner: richardszalay
- License: mit
- Created: 2010-03-24T14:04:57.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2013-01-18T05:47:23.000Z (almost 12 years ago)
- Last Synced: 2024-08-04T05:03:14.120Z (3 months ago)
- Language: ActionScript
- Homepage: http://wiki.github.com/richardszalay/raix/
- Size: 21.7 MB
- Stars: 90
- Watchers: 6
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-actionscript-sorted - raix - 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 (Frameworks / Functional Programming)
README
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](http://github.com/richardszalay/raix/wiki/Reactive-Operators) reference or the [raix.reactive livedocs](http://richardszalay.github.com/raix/livedocs/raix/reactive/package-detail.html)
### Getting Started
* [Introduction to raix.reactive](http://github.com/richardszalay/raix/wiki/Introduction-to-raix.reactive)
* [Download raix](http://github.com/richardszalay/raix/downloads)
* [Reactive Operators](http://github.com/richardszalay/raix/wiki/Reactive-Operators)
* [livedocs](http://richardszalay.github.com/raix/livedocs/index.html) (though the [Reactive Operators](http://github.com/richardszalay/raix/wiki/Reactive-Operators) is more detailed)
* The livedocs are embedded in the swc for Flash Builder 4 users
* [Background](http://github.com/richardszalay/raix/wiki/Background)
* [API differences from Rx.NET](http://github.com/richardszalay/raix/wiki/Changes-from-Rx)### More
* [Unit Tests](http://richardszalay.github.com/raix/tests/index.htm)
* [Feedback](http://github.com/richardszalay/raix/wiki/Feedback)## 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](http://github.com/richardszalay/raix/wiki/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 8Enumerable 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](http://github.com/richardszalay/raix/wiki/Interactive-Operations) reference or the [raix.interactive livedocs](http://richardszalay.github.com/raix/livedocs/raix/interactive/package-detail.html).