万本电子书0元读

万本电子书0元读

顶部广告

Hands-On Reactive Programming with Clojure电子书

售       价:¥

1人正在读 | 0人评论 9.8

作       者:Konrad Szydlo

出  版  社:Packt Publishing

出版时间:2019-01-25

字       数:35.9万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Learn how to use RxClojure to deal with stateful computations Key Features * Leverage the features of Functional Reactive Programming using Clojure * Create dataflow-based systems that are the building blocks of Reactive Programming * Use different Functional Reactive Programming frameworks, techniques, and patterns to solve real-world problems Book Description Reactive Programming is central to many concurrent systems, and can help make the process of developing highly concurrent, event-driven, and asynchronous applications simpler and less error-prone. This book will allow you to explore Reactive Programming in Clojure 1.9 and help you get to grips with some of its new features such as transducers, reader conditionals, additional string functions, direct linking, and socket servers. Hands-On Reactive Programming with Clojure starts by introducing you to Functional Reactive Programming (FRP) and its formulations, as well as showing you how it inspired Compositional Event Systems (CES). It then guides you in understanding Reactive Programming as well as learning how to develop your ability to work with time-varying values thanks to examples of reactive applications implemented in different frameworks. You'll also gain insight into some interesting Reactive design patterns such as the simple component, circuit breaker, request-response, and multiple-master replication. Finally, the book introduces microservices-based architecture in Clojure and closes with examples of unit testing frameworks. By the end of the book, you will have gained all the knowledge you need to create applications using different Reactive Programming approaches. What you will learn * Understand how to think in terms of time-varying values and event streams * Create, compose, and transform observable sequences using Reactive extensions * Build a CES framework from scratch using core.async as its foundation * Develop a simple ClojureScript game using Reagi * Integrate Om and RxJS in a web application * Implement a reactive API in Amazon Web Services (AWS) * Discover helpful approaches to backpressure and error handling * Get to grips with futures and their applications Who this book is for If you’re interested in using Reactive Programming to build asynchronous and concurrent applications, this is the book for you. Basic knowledge of Clojure programming is necessary to understand the concepts covered in this book.
目录展开

Title Page

Copyright and Credits

Hands-On Reactive Programming with Clojure Second Edition

About Packt

Why subscribe?

Packt.com

Contributors

About the authors

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

What is Reactive Programming?

A taste of Reactive Programming

The concept of time in RxJS

More colors

Making it reactive

Exercise 1.1

A bit of history

Dataflow programming

Object-oriented Reactive Programming

The most widely used reactive program

The Observer design pattern

Functional Reactive Programming

Higher-order FRP

Signals and events

Implementation challenges

First-order FRP

Asynchronous data flow

Arrowized FRP

Applications of FRP

Asynchronous programming and networking

Complex GUIs and animations

Summary

Further reading

A Look at Reactive Extensions

The observer pattern revisited

Observer – an iterator's dual

Creating observables

Custom observables

Manipulating observables

flatmap and friends

One more flatmap for the road

Error handling

OnError

Catch

Retry

Backpressure

Sample

Backpressure strategies

Summary

Further reading

Asynchronous Programming and Networking

Building a stock market monitoring application

Rolling averages

Identifying problems with our current approach

Removing incidental complexity with RxClojure

Observable rolling averages

Summary

Introduction to core.async

Asynchronous programming and concurrency

The core.async library

The Communicating Sequential Processes paper

Rewriting the stock market application with core.async

Implementing the application code

Error handling

Backpressure

Fixed buffer

Dropping buffer

Sliding buffer

Transducers

Transducers and core.async

Summary

Further reading

Creating Your Own CES Framework with core.async

A minimal CES framework

Clojure or ClojureScript?

Designing the public API

Implementing tokens

Implementing event streams

Implementing behaviors

Exercises

Exercise 5.1

Exercise 5.2

A respondent application

CES versus core.async

Summary

Further reading

Building a Simple ClojureScript Game with Reagi

Setting up the project

Game entities

Putting it all together

Modeling user input as event streams

Working with the active keys stream

Reagi and other CES frameworks

Summary

Further reading

The UI as a Function

The problem with complex web UIs

Enter React.js

Lessons from functional programming

ClojureScript and Om

Building a simple Contacts application with Om

Setting up the Contacts project

Application components

Managing application state

Om components

Query expressions

Filling in the blanks

Identity

Intercomponent communication

Creating an agile board with Om

The board state

Components overview

Life cycle and component local state

Remaining components

Utility functions

Application's parser

Exercises

Summary

Further reading

A New Approach to Futures

Clojure futures

Fetching data in parallel

Imminent – a composable futures library for Clojure

Creating futures

Combinators and event handlers

The movies example revisited

Futures and blocking IO

Summary

Further reading

A Reactive API to Amazon Web Services

Amazon Services use case

Infrastructure automation

AWS resources dashboard

CloudFormation

The describeStacks endpoint

The describeStackResources endpoint

Elastic Compute Cloud Service

The describeInstances endpoint

Relational Database Service

The describeDBInstances endpoint

Designing the solution

Running the AWS stub server

Setting up the dashboard project

Creating AWS Observables

Combining the AWS Observables

Putting it all together

Exercises

Summary

Further reading

Reactive Microservices

An introduction to microservices

Advantages of microservices

Scalability

Disadvantages of microservices

When to use microservices

Microservices best practices

Domain Driven Design

Separate data storage

Team building and structure

Deployment

Failure isolation

Cross-cutting concerns

Communication between services

Event-driven communication

The CQRS communication pattern

Common pitfalls

Attitudes towards microservices

Service boundaries

Service granularity

Service separation

Build dependencies

Services contracts

Services communication

DevOps

RESTful microservices in action

Application overview

Services messaging

A Clojure RESTful service

Setting up the project structure

Database operations with Toucan

Coercion with the schema

The Card API

Compojure HTTP API

The GET Card API

The GET Cards API

The UPDATE Card API

The DELETE Card API

The Swagger UI

Summary

Further reading

Testing Reactive Apps

Why testing is important

Testing approaches

Functional testing

Non-functional testing

Clojure unit testing frameworks

The clojure.test framework

The is macro

The are macro

The expectations framework

The Midje framework

The fact macro

The facts macro

Top-down testing

Checking for exceptions

Checking collections

The contains macro

The just macro

The Speclj framework

The should-contain macro

The should= and should== macros

The should-throw macro

The should-be-a macro

Summary

Further reading

Concurrency Utilities in Clojure

Introduction to concurrency

Concurrency or parallelism

State, identity, and value

Common problems with states

Lost updates

Unrepeatable reads

Phantom reads

The traditional solution to the problem with states

Deadlock

Starvation

Livelock

Race conditions

Other problems with locks

The Clojure approach to concurrency

Classifying constructs

Synchronization

Coordination

Atoms

Dereferencing atoms

Mutating atoms

reset!

swap!

compare-and-set!

Agents

Dereferencing agents

Mutating agents

send

send-off

Refs

Dereferencing refs

Mutating refs

Software Transactional Memory

ref-set

alter

commute

Vars

Var bindings

Private vars

Constant vars

Futures and promises in Clojure

Futures

Promises

Summary

Further reading

Appendix - The Algebra of Library Design

The semantics of map

Functors

The option functor

Finding the average of ages

Applicative functors

Gathering stats about ages

Monads

Summary

Further reading

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部