java-LearningRxjava-ch01-Thinking Reactively
前言
公司用到rxjava,學習Learning-Rxjava筆記
本書原始碼位置:https://github.com/PacktPubli...
1.A brief history of ReactiveX and RxJava
作為程式設計師,我們的工作是Modeling our world with code,object-oriented programming 很好地抽象我們的世界,但是,As 2010 approached, it became clear that object-oriented programming only solved part of the problem.
Classes and objects do a great job of representing an entity with properties and methods,但是各個entity 之間的複雜關係的抽象,使得面向物件程式設計有很多模板化的程式碼,十分臃腫,此時,functional programming捲土重來,作為object-oriented的一個補充。Reactive
programming, a functional event-driven programming approach, began to receive special attention.微軟的Erik Meijer 為.net寫了一個 Reactive Extensions的框架,後來其1.0Rx和2.0ReactiveX逐漸擴充套件到其它語言。
Netflix 公司的Ben Christensen 和 David Karnok作為主要人員創作了rx-java.其中
RxJava 1.0 在2014年11月釋出 , RxJava 2.0在2016年11月釋出。
reactiveX的核心理念是:
The fundamental idea of ReactiveX is that events are data and data are events.
2.Thinking reactively
物件都是運動和變化的
比如天氣。書本上的內容是靜止不變的,但是,當讀者看書時,書上的內容被讀者的眼睛一點點消費,那麼其內容也是變化的。也是
物件都是相互關聯的
比如天氣和人的行為。
物件的變化都是在同時(並行)的
比如馬路上,機動車道上的汽車和非機動車道路上的人都是同時執行的。彼此還要相互觀察。
所以可以使用 multiple concurrent streams of events or data happening at the same time 來modeling world