You are previewing Reactive Programming for .NET Developers.
O'Reilly logo
Reactive Programming for .NET Developers

Book Description

Get up and running with reactive programming paradigms to build fast, concurrent, and powerful applications

About This Book

  • Get to grips with the core design principles of reactive programming

  • Learn about Reactive Extensions for .NET through real-world examples

  • Improve your problem-solving ability by applying functional programming

  • Who This Book Is For

    If you are a .NET developer who wants to implement all the reactive programming paradigm techniques to create better and more efficient code, then this is the book for you. No prior knowledge of reactive programming is expected.

    What You Will Learn

  • Create, manipulate, and aggregate sequences in a functional-way

  • Query observable data streams using standard LINQ query operators

  • Program reactive observers and observable collections with C#

  • Write concurrent programs with ease, scheduling actions on various workers

  • Debug, analyze, and instrument Rx functions

  • Integrate Rx with CLR events and custom scheduling

  • Learn Functional Reactive Programming with F#

  • In Detail

    Reactive programming is an innovative programming paradigm focused on time-based problem solving. It makes your programs better-performing, easier to scale, and more reliable.

    Want to create fast-running applications to handle complex logics and huge datasets for financial and big-data challenges? Then you have picked up the right book!

    Starting with the principles of reactive programming and unveiling the power of the pull-programming world, this book is your one-stop solution to get a deep practical understanding of reactive programming techniques. You will gradually learn all about reactive extensions, programming, testing, and debugging observable sequence, and integrating events from CLR data-at-rest or events. Finally, you will dive into advanced techniques such as manipulating time in data-flow, customizing operators and providers, and exploring functional reactive programming.

    By the end of the book, you'll know how to apply reactive programming to solve complex problems and build efficient programs with reactive user interfaces.

    Style and approach

    This is a concise reference manual for reactive programming with Rx for C# and F# using real-world, practical examples.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Reactive Programming for .NET Developers
      1. Reactive Programming for .NET Developers
      2. Credits
      3. About the Authors
      4. About the Reviewer
      5. www.PacktPub.com
        1. Why subscribe?
        2. Free access for Packt account holders
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      7. 1. First Steps Toward Reactive Programming
        1. Programming paradigms
        2. Dataflow programming
          1. Statelessness
          2. The data-driven approach
          3. Data streams
          4. Observer pattern
        3. Functional programming
        4. Reactive programming
          1. Reactive manifesto
          2. The programming experience
          3. Change propagation and cancellation
          4. Linguistic characteristics
          5. Programming languages and frameworks
          6. Reactive programming approaches
        5. Further reading
        6. Summary
      8. 2. Reactive Programming with C#
        1. IObserver interface
        2. IObservable interface
        3. Subscription life cycle
        4. Sourcing events
        5. Filtering events
        6. Correlating events
        7. Sourcing from CLR streams
        8. Sourcing from CLR enumerables
          1. Changeable collections
          2. Infinite collections
        9. Summary
      9. 3. Reactive Extension Programming
        1. Setting up Rx.NET
        2. Marble diagrams
        3. Subjects
          1. ReplaySubject
          2. BehaviorSubject
          3. AsyncSubject
          4. Custom subjects
          5. Subject from IObservable/IObserver
          6. Transforming operators
            1. Delay
            2. Map
            3. Scan
            4. Debounce
            5. Amb
        4. Combining operators
          1. Combine latest
          2. Concat
          3. Merge
          4. Sample
          5. StartWith
          6. Zip
        5. Filtering operators
          1. Filter
          2. Distinct
          3. DistinctUntilChanged
          4. ElementAt
          5. Skip
          6. Take
        6. Mathematical operators
          1. Min/Max/Avg/Sum/Count
        7. Logic operators
          1. Every/Some/Includes
          2. SequenceEqual
        8. References
        9. Summary
      10. 4. Observable Sequence Programming
        1. Sequence creation basics
          1. Empty/Never
          2. Return
          3. Throw
          4. Create
          5. Range
          6. Generate
        2. Time-based sequence creation
          1. Interval
          2. Timer
          3. Timeout
          4. TimeInterval/Timestamp
        3. Sequence manipulation and filtering
          1. Where
          2. Join
          3. If
          4. TakeUntil/TakeWhile/SkipUntil/SkipWhile
          5. TakeLast/SkipLast
        4. Sequence partitioning
          1. GroupBy
          2. Aggregate
          3. MaxBy/MinBy
        5. Advanced operators
          1. IgnoreElements
          2. Repeat
          3. Publish/Connect
          4. RefCount
          5. PublishLast
          6. Replay
          7. Multicast
        6. Summary
      11. 5. Debugging Reactive Extensions
        1. Tracing sequences
          1. Materialize
          2. Dematerialize
          3. TimeInterval
          4. Do
        2. Inspecting sequences
          1. Contains
          2. Any
          3. All
          4. SequenceEqual
        3. Exception handling
          1. Catch
          2. OnErrorResumeNext
          3. Finally
          4. Retry
        4. Summary
      12. 6. CLR Integration and Scheduling
        1. Sourcing from CLR events
          1. FromEventPattern
          2. FromEvent
          3. ToEvent
        2. Threading integration
          1. Sourcing from a Task
          2. Task cancellation
        3. Scheduling
          1. Default schedulers
          2. SubscribeOn/ObserveOn
          3. Injecting schedulers
          4. Custom scheduling
          5. Future scheduling
          6. Virtual time
          7. Testing schedulers
          8. Historical records
        4. Summary
      13. 7. Advanced Techniques
        1. Designing a custom operator
          1. Designing the AsObservable operator
          2. Designing the AcceptObservableClient operator
          3. Case study - writing a reactive socket server
          4. Disposing Create<T>
          5. Designing a custom provider
        2. Designing a custom scheduler
          1. Dealing with the scheduler state
        3. Creating Pattern<T>
        4. Implementing event sourcing with Rx
          1. Creating and validating an invoice
          2. Event sourcing an invoice creation
        5. Creating Interactive Extensions (Ix) operators
        6. Summary
      14. 8. F# and Functional Reactive Programming
        1. F# - first time
          1. Introduction to F# and FRP
          2. The immutable and deduce type
            1. Type inference
          3. Functions as first class values
          4. Using the Type function for object-oriented programming
          5. Collection – The heart of F#
        2. F# – how to use it
          1. Pattern Matching and pipe forward
            1. Pipeline and composition
        3. Discriminated Unions and the Record type
        4. Active Patterns
        5. Asynchronous pattern in F#
          1. The concept of asynchronous workflow
          2. Asynchronous code and examples
        6. Functional Reactive Programming
          1. What is FRP and how is it represented?
            1. Introduction to functional reactive programming
            2. Collections and functions in a flow
          2. FRP and its scenarios
            1. Event data flow
            2. Push and pull-based domains
            3. Examples of scenarios with AsyncSeq
        7. Summary
      15. 9. Advanced FRP and Best Practices
        1. Discrete and continuous components
          1. Discrete components
            1. The discrete event example with the discriminated union
          2. Continuous components
            1. Changing continuous value and event stream
          3. Hybrid system
        2. Time flow and dynamic change
          1. Time flow in asynchronous data flow
            1. Using F# and collection function for dynamic changing
        3. Even more on FRP and F#
          1. Railway-oriented Programming
            1. Making an Observable in FRP
        4. Summary