(Ebook) Reactive Programming with JavaScript by kan - The ebook is available for instant download, read anywhere
(Ebook) Reactive Programming with JavaScript by kan - The ebook is available for instant download, read anywhere
com
https://ebooknice.com/product/reactive-programming-with-
javascript-50194990
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebooknice.com/product/reactive-programming-with-javascript-55895106
ebooknice.com
(Ebook) Reactive Programming with RxJS: Untangle Your Asynchronous JavaScript Code
by Sergi Mansilla ISBN 9781680501292, 1680501291
https://ebooknice.com/product/reactive-programming-with-rxjs-untangle-your-
asynchronous-javascript-code-5436056
ebooknice.com
https://ebooknice.com/product/javascript-cookbook-2nd-edition-programming-the-
web-50195402
ebooknice.com
(Ebook) Reactive Programming with RxJS 5: Untangle your asynchronous Javascript code
by Sergi Mansilla ISBN 9781680502473, 1680502476
https://ebooknice.com/product/reactive-programming-with-rxjs-5-untangle-your-
asynchronous-javascript-code-11056580
ebooknice.com
(Ebook) learning javascript 3e by kan
https://ebooknice.com/product/learning-javascript-3e-50195302
ebooknice.com
(Ebook) Reactive Programming with Angular and ngrx: Learn to Harness the Power of
Reactive Programming with RxJS and ngrx Extensions by Oren Farhi (auth.) ISBN
9781484226193, 9781484226209, 1484226194, 1484226208
https://ebooknice.com/product/reactive-programming-with-angular-and-ngrx-learn-
to-harness-the-power-of-reactive-programming-with-rxjs-and-ngrx-
extensions-5880848
ebooknice.com
https://ebooknice.com/product/scala-reactive-programming-build-scalable-
functional-reactive-microservices-with-akka-play-and-lagom-23390646
ebooknice.com
https://ebooknice.com/product/learning-reactive-programming-with-java-8-37720604
ebooknice.com
https://ebooknice.com/product/learning-reactive-programming-with-java-8-37699380
ebooknice.com
Reactive Programming with JavaScript
Table of Contents
Reactive Programming with JavaScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introduction and Installation
A 10,000-foot overview
An easier way to handle user interface programming
Programming paradigms
Installing the tools required
Installing Google Chrome
Installing Node.js
Installing the Starter Kit for ReactJS
Summary
2. Core JavaScript
The strict mode
Variables and assignment
Comments
Flow control
A note on values and NaN
Functions
Comments
Loops
Taking a look at ECMAScript 6
Summary
3. Reactive Programming – The Basic Theory
Declarative programming
The war on Heisenbugs
The Flux Architecture
From the pit of despair to the pit of success
Complete UI teardown and rebuild
JavaScript as a Domain-specific Language
The Big-Coffee Notation
Summary
4. Demonstrating Nonfunctional Reactive Programming – A Live Example
The history of a game with multiple ports
The HTML for the web page
Using a content distribution network wherever we can
Some simple styling
A fairly minimal page body
The JavaScript that animates that page
A brief syntax note – Immediately Invoked Function Expression
Variable declaration and initialization
The function used to start or restart the game
The function that creates game levels
Getting our hands dirty with ReactJS classes
Tick-tock, tick-tock – the game's clock ticks
GAME OVER
Summary
5. Learning Functional Programming – The Basics
Custom sort functions – the first example of functional JavaScript and first-
class functions
This leads us to array.filter()
Illusionism, map, reduce, and filter
Fool's gold – extending Array.prototype
Avoiding global pollution
The map, reduce, and filter toolbox – map
The reduce function
The last core tool – filter
An overview of information hiding in JavaScript
Information hiding with JavaScript closures
Summary
6. Functional Reactive Programming – The Basics
A trip down computer folklore's memory lane
Advanced prerequisites for Hello, World!
Distinguishing the features of functional reactive programming
If you learn just one thing...
Learn what you can!
JavaScript as the new bare metal
Summary
7. Not Reinventing the Wheel – Tools for Functional Reactive Programming
ClojureScript
Om
Bacon.js
Brython – a Python browser implementation
Immutable.js – permanent protection from change
Jest – BDD unit testing from Facebook
Implementing the Flux Architecture using Fluxxor
Summary
8. Demonstrating Functional Reactive Programming in JavaScript – A Live
Example, Part I
What we will be attempting in this chapter
This project's first complete component
The render() method
Triggering the actual display for what we have created
Summary
9. Demonstrating Functional Reactive Programming in JavaScript with a Live
Example Part II – A To-do List
Adding a to-do list to our application
Including ReactJS add-ons in our project
Setting the appropriate initial state
Making text editable
Heavy lifting with render()
Inner functions used to render
Building the result table
Rendering our result
Differentiating columns visually
Summary
10. Demonstrating Functional Reactive Programming in JavaScript: A Live
Example Part III – A Calendar
Play it again Sam – an interesting challenge
Classical Hijaxing works well
Built with usability in mind, but there's still room to grow
Plain old JavaScript objects are all you need
Progressive disclosure that starts simply
A render() method can easily delegate
Boring code is better than interesting code!
A simple UI for simply non-recurring entries...
The user can still opt-in for more
Avoiding being clever
Anonymous helper functions may lack pixie dust
How far in the future should we show?
Different stripes for different entry types
Now we're ready to display!
Let's be nice and sort each day in order
Let them use Markdown!
One thing at a time!
The holidays that inspired this calendar
Summary
11. Demonstrating Functional Reactive Programming in JavaScript with a Live
Example Part IV – Adding a Scratchpad and Putting It All Together
Adding a WYSIWYG scratchpad, courtesy CKeditor
Bringing all things together into one web page
This book is about ReactJS, so why use CKeditor?
CKeditor – small free offerings, and small is beautiful
Including CKeditor in our page
Integrating all four subcomponents into one page
Persistence
One detail – persisting the CKeditor state
Summary
12. How It All Fits Together
A review of the terrain covered
Could the Mythical Man-Month have been avoided?
ReactJS is just a view, but what a view!
Programming is fun again!
Summary
The next steps from here
A. A Node.js Kick start
Node.js and INTERCAL
Warning – Node.js and its ecosystem are hot, and hot enough to burn you
badly!
A sample project – a server for our Pragmatometer
Client-side preparations
The server side
Summary
Index
Reactive Programming with JavaScript
Reactive Programming with JavaScript
Copyright © 2015 Packt Publishing All rights reserved. No part of this book
may be reproduced, stored in a retrieval system, or transmitted in any form or by
any means, without the prior written permission of the publisher, except in the
case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Livery Place
35 Livery Street
ISBN 978-1-78355-855-1
www.packtpub.com
Credits
Author
Jonathan Hayward
Reviewers
Antal Orcsik
Sven A Robbestad
Hibai Unzueta
Commissioning Editor
Kunal Parikh
Acquisition Editor
Manish Nainani
Aparna Mitra
Technical Editor
Mohita Vyas
Copy Editors
Vikrant Phadke
Alpha Singh
Ameesha Smith-Green
Project Coordinator
Mary Alex
Mary Alex
Proofreader
Safis Editing
Indexer
Rekha Nair
Graphics
Jason Monteiro
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
Jonathan Hayward is a polymath with advanced degrees bridging mathematics,
computers (UIUC), theology, and philosophy. He obtained his theology and
philosophy degrees from Cambridge University. He has worked in many areas of
web development, with a site (http://cjsh.name/) for "after hours" titles, and he is
also interested in the human side of computing, including usability/UI/UX. His
most popular work is a piece of poetry at https://cjshayward.com/doxology/. The
faster route to get there is by typing cjsh.name/doxology, and it gets there.
Jonathan has studied many languages, including French, Spanish, Latin, and
Greek. He is currently learning Russian. He has worked on various other books
as well (refer to http://www.amazon.com/s/ref=nb_sb_noss_2?url=search-
alias%3Daps&field-keywords=%22CJS+Hayward%22 to find out more).
I would like to thank my parents, John and Linda; my brothers, Matthew, Joe,
and Kirk; my sisters-in-law, Kristin and Adrien; and my nephews, Jack and
James. I would also like to thank all of the Packt Publishing editorial team,
including a great many who I do not know, but I would like to single out Usha,
Akshay, Neetu, Mohita, and Aparna. They are the editors who left me wishing
we lived next door. Finally, I'd like to thank all those at Facebook for releasing
ReactJS as a framework that is free for the rest of the world.
About the Reviewers
Antal Orcsik is a full-stack web developer from Hungary. He works at Prezi
(https://prezi.com/) as a payment engineer. In the last decade, he worked for
Hungary's biggest real estate catalog site and one of the biggest local weather
portals. Then he joined the fantastic team that created a revolutionary
presentation tool called Prezi to change the way the world shares ideas. During
this time, he gained experience in Scala, Python, and PHP backend environments
as well as JavaScript frontend technologies, while experimenting with various
other fields of the full-stack web development spectrum. Antal is a big fan of
cats, games, science fiction, and hamburgers.
I would like to thank my lovely girlfriend for her support and patience while I
played my part in creating this book.
For the past 2 years, he has been researching travel search paradigms and
technology with the intention of launching a new project that is expected to
rethink the way we do travel planning. As a result, he has worn many hats, but
never all of them at once.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit
www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with
PDF and ePub files available? You can upgrade to the eBook version at
www.PacktPub.com and as a print book customer, you are entitled to a discount
on the eBook copy. Get in touch with us at <service@packtpub.com> for more
details.
https://www2.packtpub.com/books/subscription/packtlib
ReactJS has neither the intention nor the ambition to be a complete, general-
purpose web framework. It doesn't even include tooling for Ajax calls! Rather,
the intent is that you will use technologies that make sense for different concerns
in your application, and use ReactJS's power tools for views and user interface
development.
This book is about ReactJS, a simple and small technology that nonetheless lets
huge teams work together on different components of a web page without
stepping on each others' feet, but without a hint of bureaucratic measures. And
add some liberal help of pixie dust.
What this book covers
Chapter 1, Introduction and Installation, provides a 10,000-foot overview of
different programming paradigms, each of which has its strengths, and an
introduction to the trio of functional programming, reactive programming, and
functional reactive programming.
Chapter 12, How It All Fits Together, reviews what we covered in this book, and
we look at the next steps in a world to explore.
Appendix, A Node.js Kick start, looks at some of the good, the bad, and the ugly
of a "Wild, Wild West" technology that everybody seems to want in on.
What you need for this book
There is a bit of software to download, and you will need a web server that can
at least serve static content. Appendix, Node.js, covers building a web server for
the larger project in Node.js, but all the chapters can work with just a web server
that will serve static content in the most basic fashion. You'll need a desktop
computer, which can be almost anything that can run Node.js (if you choose to
work through the appendix). The text will work well enough with Unix, Linux,
Mac, Windows, Cygwin, and so on. If you want to run it from a mobile device,
that may be a praiseworthy approach, but please work from a device (desktop or
otherwise) using some standard server or desktop operating system.
However, all that you really need is a server or desktop, a browser such as
Chrome, a web server, and a willingness to dive into something new. Everything
else is provided in the text.
Who this book is for
This book is intended for programmers who want to dive into functional reactive
programming and Facebook's ReactJS. There is an expectation of some general
programming maturity, some knowledge of JavaScript, and some knowledge of
producing user interfaces. Familiarity with functional programming is also one
of the several things that would help, but the hope, whether realized or not, is to
create a book using which a veteran programmer in any general-purpose
language with some (perhaps light) knowledge of JavaScript and web
development would be able to get things to work.
Code words in text, database table names, folder names, filenames, file
extensions, pathnames, dummy URLs, user input, and Twitter handles are shown
as follows: "The typeof function returns a string containing a description of a
type; thus, typeof can offer an extended type."
New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this:
"When the installer starts, click on Next, as follows:"
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think
about this book—what you liked or disliked. Reader feedback is important for us
as it helps us develop titles that you will really get the most out of.
If there is a topic that you have expertise in and you are interested in either
writing or contributing to a book, see our author guide at
www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things
to help you to get the most from your purchase.
Downloading the example code
You can download the example code files from your account at
http://www.packtpub.com for all the Packt Publishing books you have
purchased. If you purchased this book elsewhere, you can visit
http://www.packtpub.com/support and register to have the files emailed directly
to you.
Errata
Although we have taken every care to ensure the accuracy of our content,
mistakes do happen. If you find a mistake in one of our books—maybe a mistake
in the text or the code—we would be grateful if you could report this to us. By
doing so, you can save other readers from frustration and help us improve
subsequent versions of this book. If you find any errata, please report them by
visiting http://www.packtpub.com/submit-errata, selecting your book, clicking
on the Errata Submission Form link, and entering the details of your errata.
Once your errata are verified, your submission will be accepted and the errata
will be uploaded to our website or added to any list of existing errata under the
Errata section of that title.
We appreciate your help in protecting our authors and our ability to bring you
valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at
<questions@packtpub.com>, and we will do our best to address the problem.
Chapter 1. Introduction and Installation
Welcome to the wonderful world of reactive (functional) programming in
JavaScript! In this book, we will cover the good parts of JavaScript, although we
will not follow it religiously. We will cover functional programming, reactive
programming, and the ReactJS library and integrate all of these into functional
reactive programming with JavaScript. If you are going to study reactive
programming, it is our suggestion that you seriously consider functional reactive
programming, including learning functional programming as much you can. In
this context, the whole of functional reactive programming is more than the sum
of its parts. We will be applying reactive programming to JavaScript user
interface development. User interfaces are one domain in which functional
reactive programming (FRP), really shines.
The purpose of this book is to provide something comparable to the monkey see,
monkey do way of conveying how to use a closure to make a JavaScript object
with private fields. Theory, as such, is not bad, nor is it a problem to introduce
theory for a discussion, but making a full-fledged dissertation's theoretical
backing as the price to do something simple is a problem.
It is our hope that this book will let you understand why building, for instance, a
game UI in JavaScript is easier with functional reactive programming than with
jQuery.
Programming paradigms
There are multiple programming paradigms around, and not all are mutually
exclusive. Many programming languages are multiparadigm languages,
supporting the use of more than one paradigm, including not only JavaScript, but
also the likes of OCaml, PHP, Python, and Perl.
Note that you can at least sometimes use a paradigm with a language that is not
explicitly designed to support it. Object-oriented programming was originally
formulated not for languages such as Java or Ruby that are specifically intended
to support object-oriented programming, but as matter of an engineering
discipline originally used in languages that predate object-oriented
programming.
The following instructions are given for Windows 8.1 (I prefers to develop in
Mac or Linux, but is writing for Windows 8.1 as a common lingua franca).
Installing Google Chrome
We will be using Google Chrome as the primary reference browser:
1. To download it, go to http://google.com/chrome, and click on the
Download now button to the left, towards the bottom, as shown here:
2. Next, click on the Accept and Install button down and to the right, as
shown in the following screenshot:
3. After that, click on the Run button when asked whether you want to run or
save the installer, as shown here:
2. Click on the Windows Installer and wait for the installer to download.
Then click on the bottom-left part of the window, as shown in this
screenshot:
3. When the installer starts, click on Next, as follows:
4. Then click on the checkbox to accept the terms of the agreement, as shown
here:
5. After that, click on the Next button to continue, as shown in the following
screenshot:
6. When asked where to install the software, click on the Next button, as
shown in this screenshot:
Other documents randomly have
different content
Yhä haaveilevana ja hajamielisenä luuli Manicamp de Guichesta
puhuttavan ja vastasi:
"Sire!…"
"Oi, sire!…"
"No, la Vallièrestä."
"Chaillotin karmeliittinunnain."
"Häneltä itseltään."
"Totisen totta."
"Niin, sire."
"Tiedustelkaa, sire."
168.
Chaillot.
"Tekö, Louise?"
"Selittäkää."
"Se on jo tehty."
"Mieluummin kuolisin!"
"Ei, ei, sire, minä tiedän paremmin, minkä arvoinen olen. Uskokaa
sanani, niin ette syöksy turmioon kaikkien halveksiman poloisen
tähden."
"Te saatte minun palatsini, saatte hovini. Oh, älkää enää pelätkö
mitään, Louise. Ne miehet tai pikemminkin naiset, jotka teidät eilen
häätivät, vapisevat huomenna edessänne. Mitä voin sanonkaan? Jo
tänä aamuna olen jyrissyt, uhannut. Voin päästää valloilleen
ukkosen, jota vielä pidätän. Louise, teidän puolestanne kostetaan
kovasti. Verikyynelillä he maksavat teidän kyyneleenne. Mainitkaa
minulle vain vihollisenne."
"Mitä?"
"Millä tavalla?"
"Paetkaa minua."
"Valhetta, valhetta!"
"Ah niin, niin, minä tiedän sen nyt, minä tunnen sen tällä hetkellä.
Sinä olet pyhin, kunnioitettavin kaikista naisista. Kukaan ei ansaitse
yhtä hyvin kuin sinä sekä minun rakkauttani ja kunnioitustani että
kaikkienkin kiintymystä ja arvonantoa; eikä kukaan joudukaan
saamaan niin suurta rakkautta osakseen kuin sinä, Louise, — kellään
ei ole niin suutta valtaa minuun nähden kuin sinulla! Niin, minä
vannon sinulle, että tällä hetkellä murskaisin maailman kuin
lasipallon, jos se olisi tielläni. Sinä vaadit minua tyyntymään,
antamaan anteeksi? Tapahtukoon niin, minä rauhoitun. Sinä tahdot
hallita lempeydellä? Hyvä, minä olen lempeä ja säyseä. Säädä vain,
miten minun on käyttäydyttävä, ja minä tottelen."
"Ah niin!"
"Silloin ei minulla enää ole mitään toivomista tässä maailmassa…
Kätenne, sire, ja sanokaamme jäähyväiset! Olen saanut tässä
elämässä kaiken onnen, mitä voi osakseni tulla."
"Miksi unta?"
"Oi, anteeksi."
"Tekö?"
"Miten niin?"
"Hän oli vannonut…"
169
"Tai kenet muun tahansa, sanon", jatkoi kuningas, "ja kun tällä
menettelyllänne häpäisette asianomaista, vaadin minä selitystä,
vahvistaakseni tai peruuttaakseni tuomion."
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebooknice.com