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

Summary

This chapter introduced some semantics of functional programming and how they apply these to Python code. This is by no means a complete guide to functional programming, but it covers everything that is needed to start out with functional programming: lambdas, closures, side effects, pure functions, and higher-order functions.

You should now have all the key elements to start writing functional and reactive applications. Hopefully, just like the many JavaScript developers using it today, you will find the architecture proposed in this chapter elegant, easy to use once you have the correct mindset, and scalable (in term of code size).

The application of this architecture on the echo server showed you how to solve real-life challenges, such as observable cycles. Moreover, by keeping the application logic pure, it becomes easy to add new features by implementing new components and using them through composition. Another benefit of this architecture that was not detailed here, however, is that testing the application logic is easy since it is pure. Many difficulties in unit testing come from side effects that are not present in this code. A typical benefit of testing a pure function is that you never need mocks, but just provide input arguments and check the return value.

The next chapter will cover in detail how observables and observers work. It will explain the different ways to create observables, how to subscribe to them, and how to unsubscribe from them. It will also explain the different types of observables, which has not been discussed yet.

主站蜘蛛池模板: 砀山县| 龙州县| 庆云县| 福海县| 扎囊县| 乐至县| 凤阳县| 忻州市| 从化市| 竹山县| 金塔县| 堆龙德庆县| 博湖县| 介休市| 沙坪坝区| 元江| 大石桥市| 扶沟县| 婺源县| 安泽县| 斗六市| 维西| 马龙县| 雅江县| 论坛| 富蕴县| 灌阳县| 新安县| 通道| 肇源县| 天门市| 清涧县| 安徽省| 南投市| 西乌珠穆沁旗| 手机| 尖扎县| 曲沃县| 沛县| 十堰市| 吴川市|