Đang chuẩn bị liên kết để tải về tài liệu:
Phát triển Javascript - part 36

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Tham khảo tài liệu 'phát triển javascript - part 36', 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ả | 13.4 The Comet Client 323 13.4.2 Introducing ajax.cometClient As usual we ll start out real simple asserting that the object in question exists. ajax.cometClient seems like a reasonable name and Listing 13.43 tests for its existence. The test lives in the new file test comet client test.js. Listing 13.43 Expecting ajax.cometClient to exist function var ajax tddjs.ajax TestCase CometClientTest test should be object function assertObject ajax.cometClient Implementation is a matter of initial file setup as per usual seen in Listing 13.44. Listing 13.44 Setting up the comet_client.js file function var ajax tddjs.namespace ajax ajax.cometClient 13.4.3 Dispatching Data When an observer is added we expect it to be called when data is dispatched from the client. Although we could write tests to dictate the internals of the observe method those would be needlessly implementation specific without describing the expected behavior very well. Besides we are going to use the observable object to handle observers and we don t want to replicate the entire observable test case for the client s observe method. We will start by implementing dispatch which later can help us verify the behavior of observe. Dispatching is the act of breaking up data received from the server and sending it out to observers. Download from www.eBookTM.com 324 Streaming Data with Ajax and Comet 13.4.3.1 Adding ajax.cometClient.dispatch The first test for dispatching data is simply asserting that a method exists as Listing 13.45 shows. Listing 13.45 Expecting dispatch to exist test should have dispatch method function var client Object.create ajax.cometClient assertFunction client.dispatch This test fails so Listing 13.46 adds it in. Listing 13.46 Adding the dispatch method function dispatch ajax.cometClient dispatch dispatch 13.4.3.2 Delegating Data Next we re going to feed dispatch an object and make sure it pushes data out to observers. However we haven t written observe yet which means that if we now .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.