This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function concatMany(enumerable:IEnumerable, selector:Function):IObservable { | |
return Observable.createWithCancelable(function(observer:IObserver):ICancelable { | |
const iterator:IEnumerator = enumerable.getEnumerator(); | |
const subscriptions:CompositeCancelable = new CompositeCancelable(); | |
var schedule:Function = function():void { | |
subscriptions.add(Scheduler.scheduleRecursive(Scheduler.defaultScheduler, function(reschedule:Function):void { | |
schedule = reschedule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import asx.fn.K; | |
import asx.fn._; | |
import asx.fn.args; | |
import asx.fn.getProperty; | |
import asx.fn.noop; | |
import asx.fn.partial; | |
import asx.fn.sequence; | |
import asx.number.mul; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Observable.mappend maps a value through a selector and returns | |
a unique Array of the input values and the result(s). | |
Use mappend when you'd rather not create anonymous value types | |
just to track the IObservable stream inputs. Takes advantage of | |
JS's ability to apply an Array as function arguments, giving the | |
benefit of more readable JS methods. | |
Pros: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2013 the original author or authors | |
* | |
* Permission is hereby granted to use, modify, and distribute this file | |
* in accordance with the terms of the license agreement accompanying it. | |
*/ | |
package org.tinytlf.observables | |
{ | |
import asx.array.flatten; | |
import asx.fn.args; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rx = require 'rx' | |
_ = require 'underscore' | |
Observable = rx.Observable | |
Observable::sort = (sorter) -> | |
source = @ | |
Observable.createWithDisposable (observer) -> | |
list = []; | |
source.map((val) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initConcatFriction(Rx) { | |
Rx.Observable.prototype.concatFriction = function (u, xS, yS, vS, aS) { | |
if (typeof xS !== 'function') | |
xS = function (m) { return m.x; }; | |
if (typeof yS !== 'function') | |
yS = function (m) { return m.y; }; | |
if (typeof vS !== 'function') | |
vS = function (m) { return m.velocity; }; | |
if (typeof aS !== 'function') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Have to do this to browserify Rx :/ | |
window.global = window; | |
var Rx = require('rx'); | |
Rx.Observable.interval(100).subscribe(function(i) { | |
console.log(i); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Subscriber = require('./Subscriber'), | |
noop = require('./support/noop') | |
; | |
module.exports = (function Observable() { | |
function fixDisposable(subscriber, disposable) { | |
var disposableType; | |
if(disposable != null) { | |
if((disposableType = typeof disposable) === 'function') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Zone.create = Observable.create | |
// Zone#setCallback = Observable#forEach/Observable#subscribe | |
// Zone#then = Observable#map | |
// Zone#catch = Observable#catch | |
// | |
// A little stub of some zone examples that map 1-1 with Rx. Instead of a zone global, | |
// the "zone" object is passed in to the function we created the Zone with. | |
// | |
// This allows us to run multiple Zones in parallel, for example, if we want to await | |
// two run two asynchronous operations (say, a file-read and a network request) at the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro parameters { | |
rule { ($arguments ...) } => { (params ($arguments ...)) } | |
} | |
macro params { | |
// group matchers | |
rule { ($x:ident = $y:expr , $rest:params (,) ...) } => { $x , $rest (,) ... } | |
rule { ($x:ident , $rest:params (,) ...) } => { $x , $rest (,) ... } | |
rule { ($x:ident = $y:expr) } => { $x } |