Asked by:
Free online Rx Book

General discussion
-
I would like to announce that the book "Introduction To Rx" is now available. It is a free book, detailing the broad feature set of the Rx framework. The content is available online at www.IntroToRx.com. You can also get a copy for offline reading in .mobi format (e.g. for Kindle readers) on the site.
I believe there is a gap in the market between the various blog posts that introduce Rx, posts that tackle a small section of Rx, the videos on Channel 9 and the existing book that is on the market. This book aims to take all users of Rx, beginners and experts alike, and walk them through the library and the thinking behind it. It will guide you to a better understanding of how and when to use each of the parts of the library. I hope that even veterans of Rx will learn some things along the way!
I am happy to get feedback (both positive and negative/constructive) as replies to this post.
I hope it helps the Rx community.
Regards
Lee Campbell (Author)
Lee Campbell http://LeeCampbell.blogspot.com
All replies
-
-
-
-
Hi Lee
I'm currently working on a team with Matt Barrett and he introduced me to your http://www.introtorx.com/ site, and it's great (thanks)! I was wondering if it would be easy for you to make an epub version of your book available, as I don't use a kindle but would love to read it on the go.
Regards
Riko -
I wouldn't put "easy" in any sentence relating to writing this book ;-)
If that is a format that people want then I will look into it. Initial investigation looks promising.
I was also considering producing just a standard old PDF and word docx formats. I have some final touches to apply from my editor this weekend and then I can focus on getting it into those formats.
Thanks for your interest.
Lee
Lee Campbell http://LeeCampbell.blogspot.com
-
Great job Lee - very useful for both my own reference and pointing others to!
When's v2.0 due? :)
-
>When's v2.0 due? :)
I will solve a couple of the formatting problems we have been having with Kindle (it is like the bad old day of Div vs Layer tags trying to generate decent MOBI formats), I will get it published up on to Amazon. Then I will have a crack at getting it to other formats (see Omer Mor and RikoEksteen's requests).
After that I will pick it all up again and get V2 done. Hopefully (but with a 1% chance) I will get something out before v2 is official. I assume the big things that people want to see in the v2 is async/await support? I also want to include a section on IQbservable in the next edition. Is there anything else people are looking for?
Lee Campbell http://LeeCampbell.blogspot.com
-
-
Awesome job Lee. From one author to another, I know how much this is a labor of love. Now I feel less compelled to write this one myself ;-) I gave my $.99 plus a quick review at http://www.thinqlinq.com/Post.aspx/Title/Reactive-Extensions-books. Hope that helps.
http://www.ThinqLinq.com http://www.LinqInAction.net - "LINQ In Action", The book is now available. Don't wait for the movie
-
On page http://www.introtorx.com/Content/v1.0.10621.0/05_Filtering.html
could it be that you copy paste the SkipLast example for what was ment to be the takelast?
Reading the book atm. Well done and much needed :)
-
Thanks for the link Jim.
A labor of love it is, I figured trying to sell a book for $10-30, I might sell 100, and after royalty I might get $70?! Not a lot of money, so make it free (or cheap) so people will actually read it. :-)
It seems that Jessie/Paul's book plus my one now fill the 101 gap. My next task will be to create the Advanced one that also covers
- Cookbook style samples e.g. How to : Read a stream, Aggregate Prices, Consume tweets, Integrate with WPF/MVVM etc....
- New features of v2.0
- IQbservable
- async/await
- RxJS
- StreamInsight
I am not sure if the wife is too keen for me to start another one though!
Lee Campbell http://LeeCampbell.blogspot.com
-
-
Hi Lee,
Just wanted to drop a note to say that your IntroToRx.com website is great! I have Jesse & Paul's book and had been doing a bit of Rx previously, but reading your site "cover to cover" was a great way to solidify the concepts and gradually build a deeper level of understanding.
Thanks for the resource! :)
Cheers, Ian
Ian Yates Technical Manager Medical IT Pty Ltd PO Box 501, Carina QLD 4152 Australia Web: www.medicalit.com.au
-
Thanks for taking the time to say thanks guys. Makes it all worth while.
I am starting to collect ideas for the cookbook now. I hope there are some helpful gems that come out of that too, but don't hold your breath, this is a long way away.
Lee Campbell http://LeeCampbell.blogspot.com
-
-
-
Amazing work! Thanks so much for writing this and making the Kindle edition available. It is by far the best "introduction" to Rx that I have found, and I learned a lot despite having used Rx extensively in a previous project. I will be recommending it to all of my coworkers and sincerely hope that its availability will speed the adoption of this incredible framework.
-
-
Enjoying the book so far; thanks for writing it and making it available!
I saw a couple of typos at http://www.introtorx.com/Content/v1.0.10621.0/04_CreatingObservableSequences.html: the first name of both Jeffrey Richter and Jeffrey van Gogh is "Jeffrey", not "Jeffery" (http://www.wintellect.com/cs/blogs/jeffreyr/, http://blogs.msdn.com/b/jeffva/).
-
-
Lee, I can't begin to tell you how helpful this book has been to me. I have been greedily poring over every word for the last few days and I feel like a kid in a candy store. Perhaps someday if you cross paths with any of us at a conference or whatnot, we'll have a chance to repay the debt in the one true universal currency (beer!) And pass thanks along to your wife for allowing you the time...mine only lets me off the leash periodically so I fully appreciate the household capital you must have expended already.
Cheers!
-
It is really great to hear that people are still getting a lot of use from the site/book. It is a totally "pay-it-forward" kind of thing. As mentioned in the Foreword, other contributions like the Git book (and Git for that matter), Joe's Threading papers, Q for Mortals etc... make my life so much easier.
Currently I am pouring all my spare time into another pet-project (full of Rx code). Once that is done(ish), I would love to turn my head to another Rx book. I think a Cookbook, or a .NET v2 version, or perhaps a Polyglot one for Scala, Java, Ruby, Javascript, C++ and .NET! In a lovely dream world, I would be able to collaborate with Bart, Erik, Paul, Matt, Joe etc...
Lee Campbell http://LeeCampbell.blogspot.com
-
-
Hi Lee,
your book is great and it really helped me to understand many aspects of Rx. Many thanks for your work.
Nevertheless just now one thing confused me. In the chapter "Creating your own Iterator" you construct extension method ToObservable for Stream and it's quite complex. I was wondering, if there isn't a better way and I came with this solution:
public static IObservable<byte> ToObservable(this Stream stream, int bufferSize) { var buffer = new byte[bufferSize]; return Observable .Defer(() => stream.ReadAsync(buffer, 0, buffer.Length).ToObservable()) .Repeat() .TakeWhile(bytesRead => bytesRead != 0) .SelectMany(bytesRead => buffer.Take(bytesRead)); }
I know that this solution doesn't use iterator and so it's not good example for your chapter. But maybe at least there can be notice that the provided example is artificially complicated to show desired functionality.
Václav
-
Thanks for the feedback Václav. The book was written for Version 1 of Rx running against .NET 4.0. Just as the book was released, so too was V2.0 of Rx and the Async features. At a similar time .NET 4.5 was also released. You are correct that there is most likely a better way, and your implementation above looks very good indeed (I haven't run it however).
I have another side project consuming my time at the moment, but I very much would like to do an update to the book one day for V2 and .NET 4.5. I even think that Scala and JavaScript implementations would warrant a mention as they seem to fit very well (not so much for Java, sorry NetFlix).
In the mean time, I have two repos that you can feel free to contribute to
https://github.com/LeeCampbell/IntroToRx
This is the SVN repo I used when writing the book. It is now a GitHub repo. I will one day set up to the build server and get auto deployments running, but the site itself was a very manual process :-(
https://github.com/LeeCampbell/RxCookbook
This is a collection of recipes that I am trying to collate. The idea is that the Book can date ( as your comment proves) a wiki style repo like this, should be a touch easier to contribute to and keep up to date.
Lee Campbell http://LeeCampbell.blogspot.com
-
I'm new to Rx, and have found the book quite useful. However, I have a problem combining SubscribeOn and cancellation support.
In an UI application, I have a request for data that may take a long time. Obviously, I do not want to block the UI thread, and I have successfully accomplished this with a method like this:
public IObservable<string> GetData() { return Observable.Create<string>(observer => { var cancel = new CancellationDisposable(); NewThreadScheduler.Default.Schedule(() => GetDataLongRunning(observer, cancel.Token)); return cancel; } } private void GetDataLongRunning(IObserver<string> observer, CancellationToken cancellationToken) { for (int i = 0; i < 100; i++) { Thread.Sleep(100); if (cancellationToken.IsCancellationRequested) { observer.OnCompleted(); return; } observer.OnNext(i.ToString()); } observer.OnCompleted(); }
Notice the NewThreadScheduler, which ensures the UI is not blocked. This means the UI layer can get the observable and use it like this (using Buffer to avoid updating the UI for every single record, and ObserveOn to ensure it happens on the UI thread):
_subscription = GetData().Buffer(TimeSpan.FromSeconds(1), 10).ObserveOn(SynchronizationContext.Current.Subscribe( items => AddRecordsToControl(items), ex => HandleError(ex), () => IndicateCompleted());
And if the UI layer disposes _subscription, the operation is cancelled. This all works fine.
Then I read the following in part 4 of the book:
When writing UI applications, the SubscribeOn/ObserveOn pair is very useful for two reasons:
- you do not want to block the UI thread
- but you do need to update UI objects on the UI thread.
Since this is exactly what I'm doing (and I like the idea of the caller being able to decide what thread it should execute on), I got rid of the NewThreadScheduler in GetData (and just called GetDataLongRunning instead), and then added a SubscribeOn(NewThreadScheduler.Default) in the UI's request.
However, although it basically works as before, it does change the behaviour so cancellation no longer works. Disposing the subscription means the UI no longer received data, but the GetDataLongRunning continues to run until it is finished. The reason is, that it is no longer just GetDataLongRunning that is running in another thread, but the entire subscribe delagate provided to Observable.Create. I.e. the CancellationDisposable object is not returned before the entire operation is finished, and therefore not tied to the disposable returned by Subscribe call.
Now, I can of course just go back to my original code (optionally supplying the IScheduler to use from the caller as a parameter to GetData), but then I don't understand the usefulness of SubscribeOn in this scenario. Is there another way to support cancellation when using SubscribeOn?
-
There is a mistake on www.introtorx.com. In the section "Other connectable observables" you wrote "The Connect method is not the only method that returns IConnectableObservable<T> instances", but you probably meant "The Publish method is not..."
Anyway, great book!
- Edited by spacy51 Thursday, January 30, 2014 4:58 PM
-
Sorry about the late reply. I think all you need to do here is chagne your code to the following
public IObservable<string> GetData() { return Observable.Create<string>(observer => { var cancel = new BooleanDisposable(); var scheduledTask = NewThreadScheduler.Default.Schedule(() => GetDataLongRunning(observer, cancel)); return new CompositeDisposable(scheduledTask, cancel); }); } private void GetDataLongRunning(IObserver<string> observer, BooleanDisposable cancelRequest) { for (int i = 0; i < 100; i++) { Thread.Sleep(100); if (cancelRequest.IsDisposed) { //observer.OnCompleted(); return; } observer.OnNext(i.ToString()); } observer.OnCompleted(); }
It would be great to see what your real code is doing. This sample code is not really in the spirit of Rx and could be further improved. eg. we could just simply do this
public IObservable<string> GetData2() { return Observable.Interval(TimeSpan.FromMilliseconds(100)) .Take(100) .Select(i=>i.ToString()); }
Lee Campbell http://LeeCampbell.blogspot.com
-
-
-
Excellent compilation and content Lee.
Thanks.
Seems a typo : variable name should be evenNumbers..
var oddNumbers = Observable.Range(0, 10)
.Where(i => i % 2 == 0)
.Subscribe(
Console.WriteLine,
() => Console.WriteLine( "Completed"));
Overall must have book for a RX developer.
-
Hello
it seems to me there's a small typo at Section "05 - Filtering - SkipUntil and TakeUntil". Where it says:
Obviously, the converse is true for TakeWhile. When the secondary sequence produces a value, then the TakeWhile operator will complete the output sequence.
probably "TakeWhile" should be instead "TakeUntil". Then again, I'm not sure if the meaning of the whole sentence remains valid or what.
HTH
Cheers
& thanks for the good read!
-
Hello there
I'd just like to warn about a typo in a bit of code found here:
- url: http://www.introtorx.com/content/v1.0.10621.0/16_TestingRx.html#AdvancedFeatures
- section: CreateHotObservable
In the second (longer) code sample there must have been some swap with "<" and ">". E.g.:
new Recorded>Notification>long<<
Apparently that happens for every occurrence in that code block, as the same thing is found in the final foreach.
Kind regards
-
-