Dab tsi yog deferred object hauv Javascript?
Dab tsi yog deferred object hauv Javascript?

Video: Dab tsi yog deferred object hauv Javascript?

Video: Dab tsi yog deferred object hauv Javascript?
Video: khawv koob yos hav zoov thaiv dab 2024, Kaum ib hlis
Anonim

Qeb: Deferred Object

Cov Deferred khoom , qhia nyob rau hauv jQuery 1.5, yog ib tug chainable utility khoom tsim los ntawm kev hu rau jQuery. Kev ncua () txoj kev. Nws tuaj yeem sau npe ntau callbacks rau hauv callback queues, invoke callback queues, thiab relay qhov kev vam meej lossis tsis ua haujlwm ntawm ib qho kev ua haujlwm synchronous lossis asynchronous.

Ib yam li ntawd, koj tuaj yeem nug, dab tsi yog ncua hauv JS?

Kev cog lus yog qhov chaw rau qhov tshwm sim uas yog thawj zaug tsis paub thaum a ncua sawv cev rau kev xam uas ua rau tus nqi. Txhua ncua muaj cov lus cog tseg uas ua haujlwm ua tus neeg sawv cev rau qhov tshwm sim yav tom ntej.

Tsis tas li ntawd, kev cog lus ncua sij hawm yog dab tsi? Cov ncua . cog lus () txoj kev tso cai rau kev ua haujlwm asynchronous los tiv thaiv lwm cov cai los ntawm kev cuam tshuam nrog kev nce qib lossis cov xwm txheej ntawm nws qhov kev thov sab hauv.

Cov lus nug tseem yog, dab tsi yog qhov khoom ncua sij hawm hauv Angularjs?

Deferred Object : Kev ncua yog ib khoom uas nthuav tawm cov lus cog tseg. Nws muaj peb txoj hauv kev daws(), tsis lees paub(), thiab ceeb toom(). Thaum twg Kev ncua ua tiav, Koj hu txoj kev daws teeb meem (), tsis lees paub(), thiab ceeb toom(). Nws hu xov tooj rov qab rau npe los daws teeb meem (), tsis lees paub (), lossis ceeb toom () raws li nws tau ua tiav.

jQuery ncua sij hawm thiab cog lus khoom yog dab tsi?

Cov Kev ncua thiab cov Lus cog tseg Hauv jQuery , cov Lus cog tseg yog tsim los ntawm a Deferred khoom los yog a jQuery khoom . Nws muaj ib tug subset ntawm cov txheej txheem ntawm cov Deferred khoom : ib txwm(), ua tiav(), ua tsis tiav(), xeev(), thiab tom qab ntawd(). Cov cog lus kwv yog siv thaum koj yog tus neeg siv khoom ntawm kev ua haujlwm.

Pom zoo: