HTML and CSS Reference
quickly as errors will be easy to track down when we run tests every time we add a
handful of lines of code.
The library needs to define the role of the observer as well as the observable .
need not be objects that conform to a certain interface. Functions are first class
work consists of defining the Observable API.
11.1.2 Setting up the Environment
For this chapter we will use JsTestDriver and its default assertion framework.
Refer to Chapter 3, Tools of the Trade, if you have not yet set up JsTestDriver in your
Listing 11.1 shows the initial project layout.
Listing 11.1 Directory layout for the observable project
chris@laptop:~/projects/observable $ tree
| -- jsTestDriver.conf
| -- lib
| `-- tdd.js
| -- src
| `-- observable.js
The lib/tdd.js contains the tddjs object and the namespace method
developed in Chapter 6, Applied Functions andClosures. We will use these to develop
the observable interface namespaced inside tddjs .
The configuration file is just a plain default jsTestDriver configuration file that
runs the server on port 4224 and includes all script files, as seen in Listing 11.2.
Listing 11.2 The jsTestDriver.conf file