上QQ阅读APP看书,第一时间看更新
Exercise 1.1
Modify the previous example in such a way that the sine wave is drawn using all the colors of the rainbow. The drawing loop should look like the following:
(-> (js/rx.zip sine-wave rainbow-colours) (pipe (rx-take 700)) (.subscribe (fn [[{:keys [x y]} colour]] (fill-rect x y colour))))
Your task is to implement the rainbow-colours stream. As everything up until now has been very light on explanations, you might choose to come back to this exercise later, once we have covered more about CES.
The repeat, scan, and flatMap functions may be useful in solving this exercise. Be sure to consult RxJs' API at https://rxjs-dev.firebaseapp.com/guide/overview for more information.