Puas yog Redux hloov tsis tau?
Puas yog Redux hloov tsis tau?

Video: Puas yog Redux hloov tsis tau?

Video: Puas yog Redux hloov tsis tau?
Video: Av tsis lim hloov tsis tau #21 2024, Kaum ib hlis
Anonim

3 Teb. Redux yog ib lub tsev qiv ntawv me me uas sawv cev rau lub xeev li ( hloov tsis tau ) cov khoom. Thiab cov xeev tshiab los ntawm kev dhau lub xeev tam sim no los ntawm kev ua haujlwm dawb huv los tsim cov khoom tshiab tag nrho / daim ntawv thov xeev. Yog tias koj ob lub qhov muag glazed nyob ntawd tsis txhob txhawj.

Tsis tas li ntawd, yog Redux lub xeev hloov tsis tau?

Rau a Redux app, koj tag nrho xeev tsob ntoo yuav tsum yog ib tug Hloov tsis tau . JS khoom, tsis muaj cov khoom siv JavaScript yooj yim siv txhua. Siv ib Hloov tsis tau . JS-paub version ntawm lub combineReducers muaj nuj nqi, xws li ib tug nyob rau hauv redux - hloov tsis tau , ua Redux nws tus kheej expects tus xeev ntoo los ua ib qho khoom siv JavaScript.

Ib sab saum toj no, kuv puas yuav tsum siv JS hloov tsis tau? Thaum ua haujlwm nrog React thiab Redux, hloov tsis tau cov ntaub ntawv pab txhawb nqa ib qho ntawm lawv cov hauv paus ntsiab lus: yog tias lub xeev app tsis tau hloov, tsis yog yuav tsum lub DOM. Ntau cov ntawv tau sau txog qhov txiaj ntsig ntawm siv immutable cov ntaub ntawv, qee qhov txiaj ntsig tseem ceeb suav nrog: Cov ntaub ntawv yooj yim ntws los ntawm cov apps.

Tsuas yog li ntawd, vim li cas yuav tsum lub xeev tsis hloov tau?

Yam khoom tsis muaj xeev los yog khoom nrog lub xeev tsis hloov tau muab kev lees paub thiab kev ntseeg siab rau txhua tog neeg siv nws. Hloov tsis tau cov khoom yog amplifying ib lub luag hauj lwm txoj cai vim hais tias ntawm kev xav tau ntawm dhau tag nrho cov dependencies mus rau lub constructor. Immutability blocks tej xeev hloov thaum lub sij hawm lub voj voog nyob.

Puas yog cov ntaub ntawv tsis hloov pauv ib leeg?

Fundamental Tenets of Ngrx/Store State is a tib , immutable cov ntaub ntawv qauv . Pure functions hu ua reducers coj lub xeev yav dhau los thiab ua haujlwm tom ntej los xam lub xeev tshiab. Lub xeev nkag nrog Lub Khw, ib qho kev soj ntsuam ntawm lub xeev thiab tus neeg soj ntsuam ntawm kev ua.

Pom zoo: