SAGA IN react yog dab tsi?
SAGA IN react yog dab tsi?

Video: SAGA IN react yog dab tsi?

Video: SAGA IN react yog dab tsi?
Video: Leng Yang - Yog Vim Dab Tsi (Official Full Song | Nkauj Tawm Tshiab) 2020/05/24 2024, Hlis ntuj nqeg
Anonim

Redux- dab neeg yog lub tsev qiv ntawv redux middleware, uas yog tsim los ua kom cov kev mob tshwm sim hauv koj redux app zoo thiab yooj yim. Nws ua tiav qhov no los ntawm kev siv ES6 feature hu ua Generators, tso cai rau peb sau asynchronous code uas zoo li synchronous, thiab yooj yim heev rau kev sim.

Tsis tas li ntawd, Redux Saga ua haujlwm li cas?

Redux - dab neeg yog lub tsev qiv ntawv uas lub hom phiaj ua kom cov kev mob tshwm sim yooj yim dua thiab zoo dua los ntawm kev ua haujlwm nrog sagas . Hauv cov ntsiab lus ntawm Redux , a dab neeg yog siv los ua ib qho khoom nruab nrab (peb tsis tuaj yeem siv lub reducer vim tias qhov no yuav tsum yog lub luag haujlwm dawb huv) los sib koom tes thiab ua rau muaj kev cuam tshuam asynchronous (kev cuam tshuam).

Tom qab ntawd, lo lus nug yog, vim li cas kuv thiaj xav tau Redux dabneeg? Yog vim li cas peb xav tau siv cov khoom nruab nrab xws li Redux - Ua tsaug yog vim lub Redux khw tsuas yog txhawb synchronous cov ntaub ntawv ntws. Redux - Dabneeg yog lub tsev qiv ntawv uas lub hom phiaj ua kom muaj kev cuam tshuam rau daim ntawv thov (piv txwv li, kev ua haujlwm asynchronous xws li nqa cov ntaub ntawv) yooj yim dua thiab ua haujlwm tau zoo dua.

Ib yam li ib tug yuav nug, dab tsi yog lub tshuab hluav taws xob muaj nuj nqi?

Generator muaj nuj nqi thiab Redux dab neeg . Nrog generator muaj nuj nqi , koj xa lus tawm nrog txhua tus tawm los , thiab koj xa cov lus rov qab rau hauv nrog txhua restart. Lub syntax ntawm generator muaj nuj nqi zoo li no - muaj nuj nqi * abc() // code here} Generator muaj nuj nqi zoo li qub javascript muaj nuj nqi nkaus xwb.

Dab tsi yog redux dabneeg hauv react haiv neeg?

Redux dabneeg yog ib lub tsev qiv ntawv uas tau siv los ua cov khoom nruab nrab rau Redux . A Redux Middleware yog cov cai uas cuam tshuam cov kev nqis tes ua tuaj rau hauv lub khw los ntawm txoj kev xa tawm thiab tuaj yeem ua cov haujlwm raws li qhov tau txais. Sagas saib tag nrho cov kev ua (saib / saib) uas raug xa tawm ntawm lub khw.

Pom zoo: