var former = function(a, b) { return a }
var latter = function(a, b) { return b }
var logger = function(a) { console.log(a) }
var numbers = Rx.Observable.FromArray([1, 2, 3])
var timer = Rx.Observable.Interval(100)
var zipped = numbers.Zip(timer, former)
zipped.Subscribe(logger)
The idea is to print out the contents of an array to the console one-by-one, each 100 milliseconds. It doesn't work though. What I've heard is that it fails because of a bug in Rx. Instead of printing out numbers 1,2,3 to the console, the code does ... nothing.
A simple workaround (Thanks Jussi) seems to work, though: Just concat your array observable with
Rx.Observable.Never
! // ...
numbers.Concat(Rx.Observable.Never()).Zip(timer, former).Subscribe(logger)
1
2
3
So, now it prints the stuff to the console as you'd expect.
To make zipping with arrays a bit easier, you could add a
ZipWithArray
method to the Observable
prototype like this. Rx.Observable.prototype.ZipWithArray = function(array, selector) {·
return this.Zip(Rx.Observable.FromArray(array).Concat(Rx.Observable.Never()),
}
I've put this extension, as well a bunch of others on Github, in my rxjs-extensions project.
I enjoyed your blog Thanks for sharing such an informative post. We are also providing the best services click on below links to visit our website.
ReplyDeletedigital marketing company in nagercoil
digital marketing services in nagercoil
digital marketing agency in nagercoil
best marketing services in nagercoil
SEO company in nagercoil
SEO services in nagercoil
social media marketing in nagercoil
social media company in nagercoil
PPC services in nagercoil
digital marketing company in velachery
digital marketing company in velachery
digital marketing services in velachery
digital marketing agency in velachery
SEO company in velachery
SEO services in velachery
social media marketing in velachery
social media company in velachery
PPC services in velachery
online advertisement services in velachery
online advertisement services in nagercoil
web design company in nagercoil
web development company in nagercoil
website design company in nagercoil
website development company in nagercoil
web designing company in nagercoil
website designing company in nagercoil
best web design company in nagercoil
web design company in velachery
web development company in velachery
website design company in velachery
website development company in velachery
web designing company in velachery
website designing company in velachery
best web design company in velachery
Thanks for Sharing - ( Groarz branding solutions )