官术网_书友最值得收藏!

A minimal CES framework

Before we get started on the details, we should define what minimal means.

Let's start with the two main abstractions our framework will provide: behaviors and event streams.

If you can recall from Chapter 1, What is Reactive Programming?, behaviors represent continuous, time-varying values such as time or mouse position behavior. Event streams, on the other hand, represent discrete occurrences at a point in time, T, such as a key press.

Next, we should think about what kinds of operations we would like to support. Behaviors are fairly simple, so at the very least we need to do the following:

  1. Create new behaviors
  2. Retrieve the current value of a behavior
  3. Convert a behavior into an event stream

Event streams have more interesting logic at play and we should at least support these operations:

  • Push/deliver a value down the stream
  • Create a stream from a given interval
  • Transform the stream with the map and filter operations
  • Combine streams with flatmap
  • Subscribe to a stream

This is a small subset, but big enough to demonstrate the overall architecture of a CES framework. Once we're done, we'll use it to build a simple example.

主站蜘蛛池模板: 山丹县| 金寨县| 定兴县| 旬邑县| 霞浦县| 若尔盖县| 营口市| 淮南市| 温州市| 新宾| 三江| 东光县| 龙游县| 聂拉木县| 化德县| 东光县| 大竹县| 诏安县| 永清县| 高青县| 获嘉县| 浏阳市| 读书| 山东省| 磐石市| 宜章县| 九台市| 宁安市| 漠河县| 临汾市| 泗洪县| 平武县| 长治市| 伊宁市| 利川市| 太白县| 丰都县| 鄱阳县| 剑阁县| 砚山县| 许昌市|