TAILIEUCHUNG - Phát triển Javascript - part 26

Tham khảo tài liệu 'phát triển javascript - part 26', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | AddingObservers 223 is undefined @http localhost 4224 . 5 Making the Test Pass Fear not Failure is actually a good thing It tells us where to focus our efforts. The first serious problem is that doesn t exist. Listing adds the object using the method. Save the listing in src . Listing Creating the util namespace util Running the tests again yields a new error as seen in Listing . Listing Tests still failing chris@laptop projects observable jstestdriver --tests all E Total 1 tests Passed 0 Fails 0 Errors 1 ms Firefox Linux Run 1 tests Passed 0 Fails 0 Errors 1 ms should store function error ms is not a constructor @http localhost 4224 . 5 Listing fixes this new issue by adding an empty Observable constructor. Listing Adding the constructor function function Observable Observable To work around the issues with named function expressions discussed in Chapter 5 Functions the constructor is defined using a function declaration inside an immediately called closure. Running the test once again brings us directly to the next problem seen in Listing . Download from 224 The Observer Pattern Listing Missing addObserver method chris@laptop projects observable jstestdriver --tests all E Total 1 tests Passed 0 Fails 0 Errors 1 ms Firefox Linux Run 1 tests Passed 0 Fails 0 Errors 1 ms should store function error ms is not a function @http localhost 4224 . 8 Listing adds the missing method. Listing Adding the addObserver method function addObserver addObserver With the method in place Listing shows that the test now fails in place of a missing observers array. Listing The .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.