1. Trang chủ
  2. » Công Nghệ Thông Tin

Learning reactive programming with java 8

146 610 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 146
Dung lượng 1,16 MB

Nội dung

Table of Contents Learning Reactive Programming with Java Credits About the Author About the Reviewers www.PacktPub.com Support files, eBooks, discount offers, and more Why subscribe? Free access for Packt account holders Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions An Introduction to Reactive Programming What is reactive programming? Why should we be reactive? Introducing RxJava Downloading and setting up RxJava Comparing the iterator pattern and the RxJava Observable Implementing the reactive sum Summary Using the Functional Constructions of Java Lambdas in Java Introducing the new syntax and semantics Functional interfaces in Java and RxJava Implementing the reactive sum example with lambdas Pure functions and higher order functions Pure functions Higher order functions RxJava and functional programming Summary Creating and Connecting Observables, Observers, and Subjects The Observable.from method The Observable.just method Other Observable factory methods The Observable.create method Subscribing and unsubscribing Hot and cold Observable instances The ConnectableObservable class The Subject instances Summary Transforming, Filtering, and Accumulating Your Data Observable transformations Transformations with the various flatMap operators Grouping items Additional useful transformation operators Filtering data Accumulating data Summary Combinators, Conditionals, and Error Handling Combining the Observable instances The zip operator The combineLatest operator The merge operator The concat operator The conditional operators The amb operator The takeUntil(), takeWhile(), skipUntil(), and skipWhile() conditional operators The defaultIfEmpty( ) operator Handling errors The return and resume operators The retrying technique An HTTP client example Summary Using Concurrency and Parallelism with Schedulers RxJava's schedulers Debugging Observables and their schedulers The interval Observable and its default scheduler Types of schedulers The Schedulers.immediate scheduler The Schedulers.trampoline scheduler The Schedulers.newThread scheduler The Schedulers.computation scheduler The Schedulers.io scheduler The Schedulers.from(Executor) method Combining Observables and schedulers The Observable subscribeOn(Scheduler) method The Observable observeOn(Scheduler) operator Parallelism Buffering, throttling, and debouncing Throttling Debouncing The buffer and window operators The backpressure operators Summary Testing Your RxJava Application Testing using simple subscription The BlockingObservable class The aggregate operators and the BlockingObservable class Testing with the aggregate operators and the BlockingObservable class Using the TestSubscriber class for in-depth testing Testing asynchronous Observable instances with the help of the TestScheduler class Summary Resource Management and Extending RxJava Resource management Introducing the Observable.using method Caching data with Observable.cache Creating custom operators with lift Composing multiple operators with the Observable.compose operator Summary Index Learning Reactive Programming with Java Learning Reactive Programming with Java Copyright © 2015 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: June 2015 Production reference: 1170615 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-78528-872-2 www.packtpub.com Credits Author Nickolay Tsvetinov Reviewers Samuel Gruetter Dávid Karnok Timo Tuominen Shixiong Zhu Commissioning Editor Veena Pagare Acquisition Editor Larrisa Pinto Content Development Editor Adrian Raposo Technical Editor Abhishek R Kotian Copy Editors Brandt D'mello Neha Vyas Project Coordinator Sanchita Mandal Proofreader Safis Editing Indexer Mariammal Chettiyar Production Coordinator Conidon Miranda Cover Work Conidon Miranda About the Author Nickolay Tsvetinov is a professional all-round web developer at TransportAPI—Britain's first comprehensive open platform for transport solutions During his career as a software developer, he experienced both good and bad and played with most of the popular programming languages—from C and Java to Ruby and JavaScript For the last 3-4 years, he's been creating and maintaining single-page applications (SPA) and the backend API architectures that serve them He is a fan of open source software, Rails, Vim, Sinatra, Ember.js, Node.js, and Nintendo He was an unsuccessful musician and poet, but he is a successful husband and father His area of interest and expertise includes the declarative/functional and reactive programming that resulted in the creation of ProAct.js (http://proactjs.com), which is a library that augments the JavaScript language and turns it into a reactive language First of all, I want to thank my wife, Tanya I wrote this book because she told me that I was capable of doing this She was with me all these months; I worked late at night and on weekends, but she didn't mind that She also helped me with the content of this book Thank you, Tanya; I love you and I dedicate this book to you I want to thank my baby girl, Dalia She is the one who makes me learn and new things One day, I want her to be proud of me—she is my sun I want to thank my colleagues from TransportAPI, especially Dave, who helped me with my English, and Jonathan and Martin, who gave me the courage to finish the book I want to thank Astea Solutions, as they gave me space to write, as well as my parents, Georgi and Dimana, who did the same for me on weekends Finally, I want to thank all my friends who supported me—Simeon, Rosen, Deyan, Pavel, my sister, Marina, and many more Thank you! About the Reviewers Samuel Gruetter holds a BSc degree in computer science from École Polytechnique Fédérale de Lausanne (EPFL), Switzerland As a student assistant and member of the Scala team at EPFL, he developed RxScala, which is a Scala adaptor for the RxJava Reactive Extensions library In this way, he contributed to RxJava He was also a teaching assistant for the Principles of Reactive Programming massive open online course on Coursera, which is the first online course on reactive programming Dávid Karnok is a research assistant and PhD student at the Research Laboratory on Engineering and Management Intelligence of the Institute for Computer Science and Control of the Hungarian Academy of Sciences He has been working with Java and related core technologies since 2005 to bring Java's benefits to manufacturing and logistic companies He was the first to port Microsoft's Rx.NET framework to Java back in 2010; however, the concept was so ahead of its time that his library didn't catch much attention until Netflix came out with the independent RxJava port in 2013 He joined the project not much later and is a core collaborator and has contributed to about 30 percent of the code in the library over the years With several years of reactive programming experience and as a core developer of RxJava, he frequently answers questions about the library on Stack Overflow, where he reviews pull requests on the RxJava GitHub project page and posts bug fixes and enhancements on a regular basis Timo Tuominen develops large-scale software projects from conception to completion for clients, including major telcos and device manufacturers As the technical lead, he has created dozens of products and services both for consumer and business use Working with Futurice, he started using RxJava in 2013 and designed one of the first pure RxJava architectures on Android His novel approach was a result of the uncompromising functional reactive programming principles that he applied to an existing platform Several apps and thousands of code commits later, he is now convinced that RxJava and FRP represent a new and better way to build software I would like to dedicate this book to everyone who has put up with my RxJava innovations Shixiong Zhu is an RxJava committer and also maintains the RxScala project He received his master's of science degree in computer science from Peking University, China After that, he joined MicroStrategy and worked on several big data projects He has also worked on the infrastructure team at Xiaomi Currently, he is living in Beijing and working on the Apache Spark project, which is a fast and general platform for large-scale data processing public class Indexed implements Operator { private final long initialIndex; public Indexed() { this(0L); } public Indexed(long initial) { this initialIndex = initial; } @Override public Subscriber

Ngày đăng: 12/05/2017, 10:18

TỪ KHÓA LIÊN QUAN