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

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ả | The Comet Client 323 Introducing As usual we ll start out real simple asserting that the object in question exists. seems like a reasonable name and Listing tests for its existence. The test lives in the new file test comet client . Listing Expecting to exist function var ajax TestCase CometClientTest test should be object function assertObject Implementation is a matter of initial file setup as per usual seen in Listing . Listing Setting up the file function var ajax ajax 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 324 Streaming Data with Ajax and Comet Adding The first test for dispatching data is simply asserting that a method exists as Listing shows. Listing Expecting dispatch to exist test should have dispatch method function var client assertFunction This test fails so Listing adds it in. Listing Adding the dispatch method function dispatch dispatch dispatch 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 .

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.