Đang chuẩn bị liên kết để tải về tài liệu:
Test Driven JavaScript Development- P17

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

Test Driven JavaScript Development- P17:This book is about programming JavaScript for the real world, using the techniques and workflow suggested by Test-Driven Development. It is about gaining confidence in your code through test coverage, and gaining the ability to fearlessly refactor and organically evolve your code base. It is about writing modular and testable code. It is about writing JavaScript that works in a wide variety of environments and that doesn’t get in your user’s way. | 13.1 Polling for Data 313 Next up Listing 13.32 makes sure the url property is set on the poller. In order to make this assertion we need a reference to the poller object so the method will need to return it. Listing 13.32 Expecting the url property to be set test should set url property on poller object function var poller ajax.poll url assertSame url poller.url Implementing this test requires two additional lines as in Listing 13.33. Listing 13.33 Setting the URL function poll url options var poller Object.create ajax.poller poller.url url poller.start return poller The remaining tests will simply check that the headers callbacks and interval are set properly on the poller. Doing so closely resembles what we just did with the underlying poller interface so I ll leave writing the tests as an exercise. Listing 13.34 shows the final version of ajax.poll. Listing 13.34 Final version of ajax.poll function poll url options var poller Object.create ajax.poller poller.url url options options poller.headers options.headers poller.success options.success poller.failure options.failure poller.complete options.complete poller.interval options.interval poller.start return poller ajax.poll poll Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. From the Library of WoweBook.Com 314 Streaming Data with Ajax and Comet 13.2 Comet Polling will definitely help move an application in the general direction of live by making a more continuous data stream from the server to the client possible. However this simple model has two major drawbacks Polling too infrequently yields high latency. Polling too frequently yields too much server load which may be unnecessary if few requests actually bring back data. In systems requiring very low latency such as instant messaging polling to keep a constant data flow could easily mean hammering servers frequently enough to make the constant requests a scalability issue. When the traditional polling strategy becomes a problem

Đã 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.