Reactive Programming in Kotlin
图书信息
| 作者 | Rivu Chakraborty |
| 出版社 | Packt Publishing |
| ISBN | 9781788470254 |
| 出版时间 | 2017-12-05 |
| 字数 | 32.0万 |
| 分类 | 进口书,外文原版书,电脑,网络 |
读书简介
Learn how to implement Reactive Programming paradigms with Kotlin, and apply them to web programming with Spring Framework 5.0 and in Android Application Development. About This Book ? Learn how to solve blocking user experience with Reactive Programming and get deep insights into RxKotlin ? Integrate Reactive Kotlin with Spring and build fantastic Android Apps with RxKotlin and RxAndroid ? Build reactive architectures that reduce complexity throughout the development process and make your apps(web and Android) scalable Who This Book Is For This book is for Kotlin developers who would like to build fault-tolerant, scalable, and distributed systems. A basic knowledge of Kotlin is required, but no prior knowledge of reactive programming. What You Will Learn ? Learn about reactive programming paradigms and how reactive programming can improve your existing projects ? Gain in-depth knowledge in RxKotlin 2.0 and the ReactiveX Framework ? Use RxKotlin with Android ? Create your own custom operators in RxKotlin ? Use Spring Framework 5.0 with Kotlin ? Use the reactor-kotlin extension ? Build Rest APIs with Spring,Hibernate, and RxKotlin ? Use testSubscriber to test RxKotlin applications ? Use backpressure management and Flowables In Detail In today’s app-driven era, when programs are asynchronous, and responsiveness is so vital, reactive programming can help you write code that’s more reliable, easier to scale, and better-performing. Reactive programming is revolutionary. With this practical book, Kotlin developers will first learn how to view problems in the reactive way, and then build programs that leverage the best features of this exciting new programming paradigm. You will begin with the general concepts of Reactive programming and then gradually move on to working with asynchronous data streams. You will dive into advanced techniques such as manipulating time in data-flow, customizing operators and provider and how to Use the concurrency model to control asynchronicity of code and process event handlers effectively. You will then be introduced to functional reactive programming and will learn to apply FRP in practical use cases in Kotlin. This book will also take you one step forward by introducing you to spring 5 and spring boot 2 using Kotlin. By the end of the book, you will be able to build real-world applications with reactive user interfaces as well as you’ll learn to implement reactive programming paradigms in Android. Style and Approach Loaded with numerous code examples and real-life projects, this book helps you delve into Reactive Programming with Kotlin, and apply it to real-world Spring-web and Android projects, thus making all your apps reactive.
目录
Title Page
Copyright
Reactive Programming in Kotlin
Credits
About the Author
About the Reviewers
www.PacktPub.com
Why subscribe?
Customer Feedback
Dedication
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
Downloading the color images of this book
Errata
Piracy
Questions
A Short Introduction to Reactive Programming
What is reactive programming?
Reasons to adapt functional reactive programming
Reactive Manifesto
Reactive Streams standard specifications
Reactive Frameworks for Kotlin
Getting started with RxKotlin
Downloading and setting up RxKotlin
Comparing the pull mechanism with the RxJava push mechanism
The ReactiveEvenOdd program
The ReactiveCalculator project
Summary
Functional Programming with Kotlin and RxKotlin
Introducing functional programming
Fundamentals of functional programming
Lambda expressions
Pure function
High-order functions
Inline functions
Applying functional programming to the ReactiveCalculator class
Coroutines
Getting started with coroutines
Building sequences
The ReactiveCalculator class with coroutines
Functional programming – monads
Single monad
Summary
Observables, Observers, and Subjects
Observables
How Observable works
Understanding the Observable.create method
Understanding the Observable.from methods
Understanding the toObservable extension function
Understanding the Observable.just method
Other Observable factory methods
Subscribers - the Observer interface
Subscribing and disposing
Hot and Cold Observables
Cold Observables
Hot Observables
Introducing the ConnectableObservable object
Subjects
Varieties of Subject
Understanding AsyncSubject
Understanding PublishSubject
Understanding BehaviorSubject
Understanding ReplaySubject
Summary
Introduction to Backpressure and Flowables
Understanding backpressure
Flowable
When to use Flowables and Observables
When to use Flowables?
When to use Observables?
Flowable and Subscriber
Creating Flowable from scratch
Creating Flowable from Observable
BackpressureStrategy.MISSING and onBackpressureXXX()
Operator onBackpressureBuffer()
Operator onBackpressureDrop()
Operator onBackpressureLatest()
Generating Flowable with backpressure at source
ConnectableFlowable
Processor
Learning Buffer, Throttle, and Window operators
The buffer() operator
The window() operator
The throttle() operators
Summary
Asynchronous Data Operators and Transformations
Operator
The filtering/suppressing operators
The debounce operator
The distinct operators – distinct, distinctUntilChanged
The elementAt operator
Filtering emissions - filter operator
The first and last operator
The ignoreElements operator
The transforming operators
The map operator
Casting emissions (cast operator)
The flatMap operator
The defaultIfEmpty operator
The switchIfEmpty operator
The startWith operator
Sorting emissions (sorted operator)
Accumulating data – scan operator
Reducing operators
Counting emissions (count operator)
Accumulating emissions – reduce operator
The collection operators
The error handling operators
The utility operators
Summary
More on Operators and Error Handling
Combining producers (Observable/Flowable)
The startWith operator
Zipping emissions – zip operator
The zipWith operator
The combineLatest operator
Merging Observables/Flowables – merge operator
Concatenating producers (Observable/Flowable)
Ambiguously combining producers
Grouping
flatMap, concatMap – In details
When to use flatMap operator
When to use concatMap operator
Understanding switchMap operator
Skipping and taking emissions
Skipping emissions (skip, skipLast, skipUntil, and skipWhile)
Take operators (take, takeLast, takeWhile, and takeUntil)
The error handling operators
onErrorReturn – return a default value on error
The onErrorResumeNext operator
Retrying on error
An HTTP example
Summary
Concurrency and Parallel Processing in RxKotlin with Schedulers
Introduction to concurrency
Parallel execution versus concurrency
What is a scheduler?
Types of scheduler
Schedulers.io() - I/O bound scheduler
Schedulers.computation() - CPU bound schedulers
Schedulers.newThread()
Schedulers.single()
Schedulers.trampoline()
Schedulers.from
How to use schedulers – subscribeOn and observeOn operators
Changing thread on subscription – subscribeOn operator
Observing on a different thread – observeOn operator
Summary
Testing RxKotlin Applications
Introduction to unit testing and its importance
Why is unit testing so important?
Writing JUnit tests in Kotlin
Testing your code
Testing in RxKotlin
Blocking subscribers
Blocking operators
Getting the first emitted item – blockingFirst()
Getting the only item from single or maybe - blockingGet
Getting the last Item - blockingLast
Getting all emissions as iterable - blockingIterable operator
Looping through all emissions - blockingForEach
Introducing TestObserver and TestSubscriber
Understanding TestScheduler
Summary
Resource Management and Extending RxKotlin
Resource management
Creating your own operators
Composing operators with transformer
Summary
Introduction to Web Programming with Spring for Kotlin Developers
Spring, history, and origin of Spring
The origin and history of Spring
Dependency injection and IoC
Spring Annotation configuration
Spring – AOP
Introduction to Spring Boot
Creating a Rest API with Spring Boot
Summary
REST APIs with Spring JPA and Hibernate
REST API with Spring Boot, Hibernate, and JPA
Reactive programming with Reactor
Add Reactor to your project
Understanding Flux and Mono
Summary
Reactive Kotlin and Android
Setting up Kotlin in Android Studio
Getting started with ToDoApp on Android
Retrofit 2 for API calls
RxKotlin with Retrofit
Making Android events reactive
Introducing RxBinding in Android
Kotlin extensions
Summary
- 批判与建构:南茜・弗雷泽反常规(乔瑞华)
- 求知文库:世界经典寓言(张潜)
- 传统中国法叙事(张守东)
- 梅花易数((宋)邵雍撰)
- 5年级全一册-计算题+应用题每日一刻钟-妙趣1+1(支伟力,何铸)
- 财务管理学习指导、习题与项目实训 专著 陈昌才,朱文峰,袁萍主编 cai wu(陈昌才,朱文峰,袁萍)
- 大学生就业指导(范崇源,姚旭东,杨梅)
- 岳阳楼(邹律资)
