Yuav tsum saib qauv muaj logic?

Cov txheej txheem:

Yuav tsum saib qauv muaj logic?
Yuav tsum saib qauv muaj logic?

Video: Yuav tsum saib qauv muaj logic?

Video: Yuav tsum saib qauv muaj logic?
Video: YUAV TSUM SAWV KHOV KHO 2024, Hlis ntuj nqeg
Anonim

1 Teb. Lus teb luv luv, Yes.

Yuav tsum ViewModel muaj logic?

Txoj hauj lwm ntawm ViewModel tej zaum yuav tig qhov nyiaj tshuav rau hauv txoj hlua uas siv los ua kev khi rau hauv Saib. Koj xav khaws ntau qhov laj thawj tawm ntawm ViewModel li sai tau kom koj cov cai rov siv tau thiab xoob ua ke. Kuv tsis pom zoo rau qhov no. Ib tus qauv yuav tsum muaj lub hom phiaj tsuas yog muaj cov khoom vim tias cov qauv sawv cev rau cov ntaub ntawv

ViewModel yuav tsum muaj dab tsi?

Qhov yooj yim tshaj plaws ntawm tus qauv saib kom nkag siab yog ib qho uas ncaj qha sawv cev rau kev tswj lossis lub vijtsam hauv 1: 1 kev sib raug zoo, xws li hauv "screen XYZ muaj lub thawv ntawv, ib lub npe, thiab peb lub nyees khawm, yog li tus qauv xav tau ib txoj hlua, ib phau, thiab peb cov lus txib" Lwm yam khoom uas haum rau hauv cov qauv saib yog …

Puas ViewModel muaj kev lag luam logic?

ViewModel: ViewModel yog txheej nruab nrab ntawm qhov pom thiab qauv. ViewModel muaj cov kev lag luam logic, uas tswj cov ntaub ntawv kab los qhia hauv qhov pom. Txhua yam kev ua haujlwm thiab cov txheej txheem yuav tsum yog nyob rau hauv tus qauv saib. Lub iNotifyPropertyChanged interface yog siv hauv ViewModel kom ua tiav ob txoj kev khi.

Yuav tsum ViewModel muaj qhov cuam tshuam?

3 Teb. Interfacing koj VieWMModels muab rau koj cov txiaj ntsig ntawm kev thuam lawv hauv kev sim, cuam tshuam koj cov Views zoo li qee qhov overkill tiag. Koj yuav tsis hloov koj cov kev xav thiab kev ntsuam xyuas UI tuaj yeem ua tiav ntawm kev thuam ntawm koj tus ViewModel yog li koj yuav tsis xav tau cuam tshuamlawv kuv xav. Nws yog ib qho overkill.

Pom zoo: