Matthew Podwysocki mattpodwysocki

View promises-observables.js
1 2 3 4 5 6 7 8 9 10
// Observable to Promise
var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
promise.then(console.log.bind(console));
// => 42
 
// Using config instead of argument
Rx.config.Promise = RSVP.Promise;
var promise = Rx.Observable.return(42).toPromise();
promise.then(console.log.bind(console));
// => 42
View simple-backpressure.js
1 2 3 4 5 6 7 8 9 10
Rx.Observable.prototype.pauseAndResume = function (subject) {
var source = this;
return Observable.create(function (observer) {
var q = [], previous = true;
var subscription =
source.combineLatest(
subject.distinctUntilChanged(),
function (data, shouldFire) {
View from-promise.js
1 2 3 4 5 6 7 8 9 10
// Submit the form when the submit button is clicked
var signUpCommand = function(emailAddress) {
var promise = $.ajax({
type: 'POST',
url: '...',
data: JSON.stringify({
'email': emailAddress
}),
contentType: 'application/json; charset=utf-8',
dataType: 'json'
View combine_latest.rb
1 2 3 4 5 6 7 8 9
# Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
def combine_latest(*args, &result_selector)
AnonymousObservable.new do |observer|
n = args.length
has_value = Array.new(n, false)
has_value_all = false
 
values = Array.new(n)
is_done = Array.new(n, false)
View amb.rb
1 2 3 4 5 6 7 8 9
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
 
require 'monitor'
require 'rx/subscriptions/subscription'
require 'rx/subscriptions/composite_subscription'
require 'rx/subscriptions/ref_count_subscription'
require 'rx/subscriptions/single_assignment_subscription'
require 'rx/core/observer'
require 'rx/core/observable'
View buffering.js
1 2 3 4 5
var source = Rx.Observable.interval(100).bufferWithTimeOrCount(500 /*ms*/, 50 /* items */);
 
source.subscribe(function (arr) {
// Have chunked array based upon time or count, whichever hits first
})
View scan.rb
1 2 3 4 5 6 7 8 9 10
# Applies an accumulator function over an observable sequence and returns each intermediate result.
# The optional seed value is used as the initial accumulator value.
# For aggregation behavior with no intermediate results, see Observable.reduce.
def scan(*args, &block)
has_seed = false
seed = nil
action = nil
 
# Argument parsing to support:
# 1. (seed, Symbol)
View defer_test.rb
1 2 3 4 5 6 7 8 9 10
def test_defer_raise
scheduler = RX::TestScheduler.new
 
invoked = 0
err = 'foo'
 
res = scheduler.configure do
RX::Observable.defer do
invoked += 1
raise err
View as_observer.rb
1 2 3 4 5 6 7
def as_observer
Observer.configure do |o|
o.on_next &method(:on_next)
o.on_error &method(:on_error)
o.on_completed &method(:on_completed)
end
end
View synchronized_observer.rb
1 2 3 4 5 6 7 8 9 10
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
 
require 'monitor'
require 'rx/core/observer'
 
module RX
 
module Observer
 
class << self
Something went wrong with that request. Please try again.