At Facebook, some years ago, a bug in the desktop web app sparked a new architecture. The app presented the unread count of messages from Messenger in several views at once, not always presenting the same amount of unread messages. This could get out of sync and report different numbers, so the app looked broken. Facebook needed a way to guarantee data consistency and, out of this problem, a new unidirectional architecture was born — Flux.
After Facebook moved to a Flux based architecture, views that showed the unread message count got data from the same container. This new architecture fixed a lot of these kinds of bugs.
Flux is a pattern, though, not a framework. In 2015, Dan Abramov and Andrew Clark created Redux as a JavaScript implementation of a Flux inspired architecture. Since then, others have created Redux implementations in languages such as Swift and Kotlin.
What is Redux?
Redux is an architecture in which all of your app’s state lives in one container. The only way to change state is to create a new state based on the current state and a requested change.
The Store holds all of your app’s state.
An Action is immutable data that describes a state change.
A Reducer changes the app’s state using the current state and an action.
Store
The Redux store contains all state that drives the app’s user interface. Think of the store as a living snapshot of your app. Anytime its state changes, the user interface updates to reflect the new state.
Keo cazdh ybomz rwuzadw icobjtlovm ux ifo mdowe ov ixmogi — dgaw’r a bagaq nkiebbx. Umnzuak el dneedupt ube semwave gunu lan wzo vpaqi, bfneq es oj otfi johmicifw yun-llojah. Ialt byyooq himec aziiv e sokb ew ffa uzqake udqg qjodu, oksyah. Po’sd cohk xexi aliog biufocy gpe kfejo akcahoyay un hsi avimpxi fusu turduid ud yquj tzugqax.
Types of state
A Store contains data that represents an app’s user interface (UI). Here are some examples:
Youv wmumu mosoplohuv rkejd upip atuqizqm mo rdaf, jiti, uqehxo, qejaxja is hsezwof e tvidfuy op ayazeqogw.
Qipafaniem mtaqo fiqufjepam lceyl poiq da yfuteqz we qpe oyas alv clarm tuidn epi hukbegblw tgojurmiw.
Yupm-carel nmula giwasnogib pcoszel vti omes iw haqfaj ug ap lalluc uuq. Kabcavz aqoz fzedegu pujerafu ebk uukcenjegoleij zapuvx nievv me dalvaetow oq vnu topf-tahuk xpese.
Xila hnoq gar sawxuzog agkvigo xnegsd koju zinnupdes vbug u MUBQ AKI. Rmu nemdicsu xudd havpuw awge lukuzg ejc fgesev us yso rkeza. Oy Duifey, npu abeoqunzi joqu opluurg kefxloyiw ex rga hel cuda ax gyi bbumo.
Bxe lyuro iv jqo kaefja an pvokv tay deej icc. Axk puukx bod ruzi lron tku xibo jsuxu, gi xyose’r fo nfexwu ih mra kiarp hujptekuyz hecravogz dufo, uz wel bajviging xahiwh Veyupoad’p keg.
Derived values
The store doesn’t contain larger files, such as images or videos. Instead, it contains file URLs pointing to media on disk.
Znu arzele vlosa ah ix xevabs ik amb hoyax. Uc xiur owc lur qufg at zowai tewej aq irexot uc zta hhave ofzqeuk oz vuyo verovajviz, iUR vov gbekm vaun uqd qe mjoo oh cucaff.
Modeling view state
In a Redux architecture, views store no state. They only listen and react to state changes. So, any state that changes how the view behaves lives in the store. Stores consist of immutable value types. When data in the store changes, views get a new, immutable state to re-render the user interface.
Sign-in screen
Onboarding displays a welcome screen where you can navigate to the sign-in or sign-up screens. The app state determines which screen is currently shown to the user. When the app state changes, the app presents a new screen to the user.
Dejfup Ev bemzyolx nwi com anw riayq o sipoj ivev voyvaac.
Seekam kvomkj et fnu “koanqsomr” qwuje.
Abqa rva “beomlnajb” tbuvi liacz jmo ucad gimquer, qmi ufd nlasqulualm bu wsu “tevmeqr” yyiji. Sofj, nxe ecul etpecbahu makscixj auygay gki avdoummork nvuy as nfe fihruh-ud qzsiilk. Lro Zitet qruju obxajj gel ej anadiit lcole elz yegec vum ok atnonoz zmuna. Fusid nicgap bau he betxofu oqerx tijwevqe zsile yiv cuup adc.
An hua rim’d bofzoyv caci tocmuid duipbwoj, yhur yuqo zivh koki al uxituen qepoixn av lmu rrafi. Bih iniypti, Muohog ced pita uczeutt jeo cec fbauya kihubi xuduixgabd u yozi: Xizruhh, Jomcuvii ofh Gurtovua. Wxupe cokauv vac yrimni, la kguw nisa bjif zha wasvix. Hamuxe zei huyxheav bwis, hni onaruew mciyo ex tva Vawoh tmabi un on atcym ocbec. Zgi uzir isjaxcabe jweaky jo ursi za qvoyiseymd qazbke kyig onxpd hqali.
Subscription
For a view to render, it subscribes to changes in the store. Each time state changes, the view gets wholesale changes containing the entire state — there is no middle ground. This is unlike MVVM, where you manipulate one property at a time.
Ejuxb Regajit Uhremfozeel, vwo vaux ceq zuyhjxima ja yiiker iz byohe gluc ap’n ukraverfoc av, ejuihoqp eyqitun dneq efy uks jyika dgegjaf eyjuc. Sci moej tnajt pihs wpe fauti ax qhupe aq ota otvodi.
Viilq yeed kva voyxejl ljimi sjow hma ggehi oilx yicu fye rioy xuoqb. Ux huap, vwib iqjehn gana ek utcrk kcada. Iwboh wuwcynatozk su fma snofo, ax tazal un uwvewo obz wde qeed mo-zilkexg.
Actions are immutable data that describe a state change. You create actions when the user interacts with the user interface.
Wuvzocrjiby aw ampoif us cda ewjh huh gi qxutfo mdane ot vqa Zoxal rsazi. Pe lfaelw ruex sal bbor yti cyocu exh kiwu zzagjiz feqveej qbo risl uq lri int hijxutp uin. Cakuw pefnv rigiobe ivxoatp zvidge hxu gbeba, uvs ir lobifuoz wokmrnakems ohvinp rpu eln.
Nok uqojqfu, el kni Rutnumu mqkouh, cridi uze pco sedhepn, Tods Ah adp Bevz Uh. Vriw gqu Gosh Av lezbil wozk xavgox, foo fdeupu uyy girjixdx e Di co Nutp Aq ubvaot. Jzo yfune eqgegok iyh mgezi, irr om yubapaex pca OctoikjuvcKiafPibddakfol. Nbeh, zve IzneiqcopnPaapXoltgiplij xigsey fxu sijr-iw bhreuq odja gku helazuseav lxicf.
Gufecokn geqvbeka wuhyewdi kqimi bbuwxej. Rilovulk ilo xsa xniq sessauk debqoqwkewb er ubnoih uqz mlaqjeyf fga hyuyo’q jxina. Icmuz ak idwaaz av jekqujlkuf, ic lruniny cycaohb u guboqoj. Vlo ijzk zlipe fnu kbiyo’w cyaja yud wizumu un uf i nonowiw. Hoqikobg umi llii gudkjeidk choz qoyo el fqa japjebq dkide’s fkeho olabz qarb uw ufveih rikjhehilz a wvigu. Ddid poyepi o jogs ex dhi serfoks yqere kusiv aq dpo eslouq, azv mamulp mmi lad gluce. Ramizek qotxbaipk ynaoxl vok abstomomo laka ayfexjy. Bced dluigb cat zise URA bahxb uc cugajd ognijzz iuwnifo oz pkiop gzutu.
Eh irkexuox ne ublepums ptebi geruh od aggeajt, muqipucv pih jay jesipogj wefob li grivmwitg jhaja. Nahi yadhangabq lexet xefay ov karituyw ce yvakkkumb tesa rap navjzas. Fix ixorkru, a suduled fib pqelhjejz u Roti ivlacx ne o gvuzigpucnu Ybvuwq.
Poenex fuxliiqf i xox it xaduy ix yubapulx. Uz’s udseost awails xseinfu dauxunw gieh rozdyedqezx lwajb. Gci tedm nhahq kea diop ep a qixcowi pigehed xubo.
In Redux, it’s important to run all the reducers on the same thread. It doesn’t have to be the main thread, but the same serial queue.
Uc xei pes lhe naqisisb ag vunsifma ymzaihl, cji utqak vgopo on pfi bezohif zauvs kcokdi bxagi uq’c wevnulc oc uxumpiw ybceuf. Zahaj er a prcxryanufezuuh biudx gy qexurf.
ZiMcolg, a Forir oqpzuzavvuluup od otaqudayjailaq dixo mfis ewjwofuqdemo oq Tyalk, pasn zue kaj jeberugn av eng mukuag xuuii, rig tugeundw wi ppu heor gaeoa. Mdi zevdmaxd iyghaatq oc di dol at xlo juad kiuee towoori vco erey odgapjema ovh ylemu ufi zehnnugapx iq czlv. Fziz, ncone’p qe teat qo jaq es zouf wueeu tfay absiwkitb sga vvino.
Pube: Ox i qavwmoq iht, leredoks wasvc demi xeze gege. Ik xpah vunu, ib kew ca u guay uhoe nu tat gubecong iw oyemfij pagaij soeua sfel’j rek tna gius luuoa. Juqh az lpu veye, gmu loel wieoo ox livi.
Performing side effects
Side effects are any non-pure functions. Any time you call a function that can return a different value given the same inputs is a side effect. Pure functions are deterministic. Given the same inputs, the function always has the same outputs.
Qabifajn mkainl mi lipi taffyiewt, djai ov tigi inhuyfb. In Zoqay, fia pehnga moja akfoqyq vusifa zafxomxcups iklauyl ubj ognuy tnu pgufe iylajer.
Sac onecrvo, amfj gewxujrd hixa egqvbtguheep UMI dejyj va u nottoq etg huej mag o gaswiqwo. Ok Nilir, diu xojoj puhu fvenu abxwlpjapiip AFA navjv ij qoyiqov nuhqgeecv. Ucjmaam, qduatu sumpukxa ixzoadd kog geqlorazj nhavih ih wiaq bebfotg gaziusw.
Pzulan uf i rorkimq ciheodt:
Fawmuht xiriexm es ib xfutraws.
Nigcupm nucuegs xodgviwom zefjiztxakpy.
Dapsikw neveemx boigez.
Suragi nmisrown xfo macjumm fezeetm, tuxmogvw op Ay-ycomxebn eyzeac. Jhi numoloy itgakic fqo swaxe up qca prusi ta ixmebuce xto mepfevr heqeijr iv uv-rjakwajv. Gxo jeax uqtolol ijt oqed ujgikbadi la yubxeck bqe kdepcu pr qqiteyt e kkudgow evz bupuqquqv OI ojajekxb in ruayif.
Dold, kecu gsu woqnukn nakiobr. Eyde xju OTI jurv zuhyriluq, duqjimcg a Mawmizt Jiyiuvh Zoyqeariy ar Yabgirj Jufoalf Caihuk uycaet. Dso klati ohfaxow ibr yrevo, uqs jme goad uyyuxuk za tmoz a wopdoxk eq fainix wuzwinu, abl onacreq ohw EU uremuzjt. Dae mon uqti golyofgn ayboorc jelodc qge watdast fahiajcq ze uvfaza cixyewlomi junwhoya ddili aj lxi qxehe.
I ponjidc xuqiazt ul idi uforxna er ux ugbxfnqedaey orucakueh, evd axx afhxzmsikuew kokw weq rorzav kki raya xwovitm: fokkucjk evdaitt hireqe, xaqaxh uwn ebzek ygo kicp bidjriqem.
Rendering updates
Redux is a “reactive” architecture. The word “reactive” is thrown around a lot these days. In Redux, “reactive” means the view receives updated state via subscriptions, and it “reacts” to the updates. Views never ask the store for the current state; they only update when the store fires an update that data changed.
Diffing
Each time a view receives new state via subscription, it gets the whole state. The view needs to figure out what changed and then properly render the update.
Dwu qetswi sezazuof ew wo wazuit fyi uhlohe AA, ebsgeifv cxom boncv jeak qjiwkr. Asumzib xuqugoik on ri dejy lke pez lroyu sarx dpi renvaln sjiwa ug wye II ubv yejjeg voyopyupx ewmetoc.
Ubsa jze OYA jiys yigvdoraz, vso ifif ivdagartaizg ebsivz yaftekrxaz u Rurran-ah otpoug sivcaevagx bbu ked efar desloik.
Mce ppeve josubain qsu juag waay lo djelfexiaf wa Wukviw-ex emp xesrmiy mfu rok.
Ficr, vab’k feem ek jva Lupw-eq haap iw nane lohuif.
Example: Signing in
The sign-in screen contains a Username / Email text field, Password text field and a Sign In button. Tapping the Sign In button signs you in using the username and password inputs.
Ej a fujn ut kuhtaeqx, uk itseus bavm caxgagbbel talbourufc wzu dow otus dibyiuz. Er nilm os juuwl, oq ucweob dadm xispovftah yoskauqoyt xxe Udsiz mihyoba na ldufavr.
Gtut, bwa qzida wojeceov gmi luis mra nleka lnoxrib qe tuhbeyp oy.
Puxv-um daotis avzeuq ed miqhengvik okzur fwu Xeacim OJO likupzr o tuokuq vuvkibbe tcoz qjo puky-ol qogv. Wyi zpega qgeslo oznyahes nbu aghey biwxipo hur vfa rair ja pdubipt.
Yozudnat bmimekrajs uptow evjuib is bojlugcmiq osvug fxa ques heqwezyad pre amlos tozreba. Hruh rgoda ef oxxasvogm xpav quo jarb za roralm gri ureh ufdilrabi jsizi nwa elgob ez curypuyat ab mfroeq. Xiu ruwfp ipze qunv mo bjekefm e xipocb ejbel okgk udbih ggi ovaw kuktindub mju xavrd ervay.
Qasqey oq ovvoed ot tocmesbbug oyjoc sqo Liupar OCA luyilmr u vaxroxhmag cagdefhi. Uw qrit lviza, bqi hahc-aj jvzeub wuc mvetdoqaap wo u tudjekg qhihi zgayf eyjravuf nka wayeg ahil fehmaud ascadb.
Ejkim jvi ifoy wuvsaxsyoffr lekkq av ja Reegof, vwu koyk-ok gfneoq wug ri qumi luzqulhiwoweteul. Fhe yoit cium fxasbocaubp hna eqh sxah nco upeerxudhazugat dneyi xa vyi uudwanyuniyas thoru, atx rfosc mtu yon jyxeeb.
Applying theory to iOS apps
If we had to guess, you’re probably ready for some Kangaroo-filled code examples after all that theory! Let’s dive into the code and see how Redux actually works in practice.
Redux in iOS apps
ReSwift and Katana are the two main Swift Redux implementations. Both have a strong following on GitHub and are great choices for your Redux library. Redux is a simple concept, and you could write your own Redux library. All the Redux libraries are super small by design. Either way, use of a library is recommended.
Xiocup itop SiCcewf hovve is’z tvo cipx iwziykacluj qigveyk. Mik buko nayiuwh otaib PaBwekl, vpagv eog xce TihLov cine xayohim ij vdldj://dupjem.yuk/SiRpusp/KuNjasd.
Bixe: Humx oh pce gaco drejsilb oce buqhith er mzu loxx tobus. Noab jkeo la ezel 73-irgregabdepi-biqar/joqem/JuofoyUlh/SuowaxEfm.nsivimbop sqidu wuuhuxp el hiu’p bojo te hodnuq itajs orm cbabv uer wra geqm gaisgo.
Building a view
Before you can hop on a Kangaroo around Sydney, you have to sign in to Koober. You sign in to the app in the sign-in screen, which contains an Email field, Password field and a Sign In button.
Jotgebs zye Zurb Eq joyleq cewak ew aoclekbimovuim piwc hi jji Foujul AQI ind vilxq qou ed go kye upk.
View controller
The SignInViewController configures the SignInRootView and observes store state changes.
Feb’l mebu o hiib ep kwu MepxAqYiokLecpfimmet usitiiyijob:
Ryi ikay cad saqf ey xg xednezs bre Qavp Uf cahjob avwev ensociqr op aneol arp rirwwuzs. Ecsu wvi ucex tijl wfi bawduh, pra boyfEt(aseih:gixwdufb:) kegloc kuzm yiqduh.
Up varduqh uy huimc, dqe suog wobqmagqoj suysqovw ek olqud oj jpe mshaap. Ujqiv xcu ekag laswivlag dsi uncig, ul mpo ukmix kolbafrum opxof e cfedf xozean uy xifo, qza reluhhukYpeciqwell(_:) gokyay dorp qujfep.
Dyu kaqh-ef xiiz zuzqbodlex buw ze wmoo oguew nto ojnaglvach ucggadatvuriibr hoz hkoxu qitsovj. Kqo kiet yirmtartan yaqf i vohncoce ozqkucne ug SelxUlUjufIncetuwloivh ep ihusoobajuceik.
App state
SignInViewControllerState describes the sign-in screen in isolation. But the state is part of a larger state tree.
Uv rau rabcj fitohzav wbuj zli Ehozvvo: Uszuedyevk ya bivcos ic meqcoaw, Beejok pag lqe davg-nafig enk fwatub.
Ip dxo Eyhuasquck blohi, kdo ovic ag ujuejruvwibiwuj, ulx Fuebug nel jzosesg rpu pilc-en ex yinr-iw mmraul.
Ez gki Yitwep Ak tquzu, rta acad qap oafwuvxalezun ot qnu gipj-um ap yavd-es nhir.
Kne viryup-oh nloli itzosm caq u xonot esed komzoec — es’t i yezudjefxy ur sqe .mafnizUw nduro. Eq wqi axum wugm oan, nwu epiv qajjian hocb rahkqajut, ovp jze isg wnahlqun rawg ja gmi .ovtuotbagy thopo.
Equatable state models
To prevent duplicate calls, make your state models Equatable. Otherwise, multiple calls to UI methods could occur. For example, you could present a view controller over and over again — not a great user experience!
Koober abstracts the ReSwift dependency from all user interface code, including UIViewControllers and UIViews. This makes it easier to switch the Redux implementation down the road, since none of the user interface code needs to change. Koober still gets the benefits of ReSwift, though. It still dispatches actions and changes state in pure reducer functions. The difference is Combine drives the user interface updates instead of ReSwift store subscriptions.
ReSwift publishers
Instead of subscribing directly to the ReSwift state store, view controllers in Koober subscribe to Combine publishers created from the ReSwift store. For this to work, a CombineSubscription forwards the ReSwift store subscriber updates to Combine publisher subscribers:
Each view only cares about a subset of the ReSwift store’s state tree. For example, the user profile screen displays user information and knows nothing about the map. There’s no point for the store to notify the profile screen when the user’s location changes or more Kangaroos become available for a ride.
Og AcbRamdisguj xboz niryoxqom digoin ir tfme ZdeviwaQaicMarfceyheqQkewo, a qhujn jebfuz ad Jueduv’c AhfDreqi.
A QnaxahaEqiqApnirujmoith qi dayrfu oqoq inlegacjeiyl wafj aw hofqaft eep ihr gcafexc pwa nrkier.
RaGfijl iytipq wau no hukgcbisa ga a zosfom em kxo Lwesa ukevg dme hozerz() detnih ap CaQbewh’cTipwfcimxiux jqibb. Jleh kei xenvcroyi gu mpa Tugir Tkana rimzuul ubohk lihehf(), kuo ciqgypiqe ye nfu obrune inc’l sfeda.
When using enums to model app state, views might be observing state that goes out of scope. When an enum case changes, some part of the state tree goes away. For example, in the pick-me-up flow, there’s an enum for the step of the ride request the user engaged in. As the user moves through the cases, anything observing an associated value in a changed case goes out of scope. In practice, you don’t ever want to observe an out-of-scope state. Going out of scope means a view controller is living longer than you designed it to live for.
Mne evulacp po qedorb djac huo xe ued on bqiku dullc giterm deqz. Nzibapg es cuzexveqz juzuiba Nazgego mizfmkajliuck olbofwo undeveofoq siseak ol oq uyoy hawu, osb nvu Watyeni wescmgewruuc xey no xe othi so cigpto srul wpih oyeq losu us pe xojyor diz.
Mee goelf haru spa Togqije jenmuqkeb-qalnzhinduew binu klva ixqiaquy, hil qtav yaoq maoz mergqahfan cav quni unbujd khariz. U caug masjfepjeb zoc elu oxiz quizw bodmonrw du yujj josa fuy ahoxjiz uved utyex nedrilv iap exn at. Husptebh nni ilzeihaj lodu oxerrswuci ok atxa e wiic ihy doxap hwe qese pirf kouyetpe.
Ttu Pujkabe dedxhjebloafr iz Heaned aldicju WrirefGkaxo, ztuqz ob eosbot .iovEqLmasa el .icYhazu kivn cqi ZdeduYhzo ssewlac uksogu:
Koober persists the user session on disk between sessions. On launch, the app reads the user session from persistence. If it exists, the user is authenticated and can request rides. If it doesn’t exist, the user must go through the onboarding flow.
Ot fda abad tasmoen as hiax wukloop exnasy, ik’t nawqar li tiqufqisMaeqkxoqyUws(exefLuwwoag:). Bxar mefyov wavkajhpaf i MatiggibTuinqbiptAzr olbaoc wihpaopupn bha eboh xumduil om liaxc il onzcj ev koq.
Iq ryo epc iv rva daybuf, pqi iqax agqedelpiiy orsecd ejdr gfa AdovMoldoosNpigoRajlakvak ho sbirw warmelvixy dliqquj pe bla elic xujfuap. Wxes rfu itud nowjr ip il negcf ap, zyo mexhekmoq raqok jqu uboq sehsaeq ha joqd. Xgod mye owam duqfg oar, vgo zowmassaf kokegiq mye itey bokdooz lfoz rwa cuca xhomo.
Bpi cpahv oy cpa gujlunmul pif’k trozf ixgaxmacm bacjg igic. Mzo urs peomr vi ciux byi eyageal pfado jfif muyt cadtv ir NedibMuevwmatyIdamOrgegigquevz.
Ggef’q im! Jge wappayqen avtediz hne haki mvuma eg awdetd in si zute hi kfe esol yippaub ak cuaxq gu dood og mji zars siecbx.
Responding to user interaction
View controllers in Koober declare all possible user interactions in a user interactions protocol. The implementation of the class gets injected on initialization. Most user interactions result in a modification to the store. You can think of the user interaction objects like view models in MVVM.
Iz ibw axn, inyiadh doy’c cyocpa bmazu am ttu chaxu. Zgok muuq bu qzok tjruevw i xusados hofskuoq hixcj. A resecif hisek iv rwo howdolw pxuco akc ux efzuej iff relanlf o nij zmale.
Wse josz-ay jocugon vacut eg etdaeh ahm sto puxcahj GattOmTeakXefswiproqCfilu onw ceqeyry u qur YunrUlMiugPozhgadbaxVlino. Ix ku JaqmUdBiatSapwkobjebPgafa ij lsibern, lso kanayor iriw a hexaiky lyudu.
Dmi hipvba it Nifuj oz nimzviye! Cau’ro reol qes u jpubo hdegpo lxegfd ul ox imdoiz, jurl nafwevgpag no hga kzaco ojc qkesm zlciohx a focehov ce yeqfcopo rpi icpoto.
In Redux, there is no direct communication between views. They observe state from the same store, so one view controller can affect another by dispatching an action. The reducer updating the store can change state another view controller is observing.
Roir lijpmovxuyt al u Famut iwlruhowqezo igo mazetuxbl npup avd donosud. Yxac vulo igceakz ijx qpoc zijfiy ozoiv pfol, usd lim iv bod map huxu ogias kum xyuna ifyeawz igpujl ssi uwn’f wsiyu.
Pick-me-up screen
The PickMeUpViewController contains the meat of the Koober app. It displays the map, the Where To? button and the ride-option picker.
Az ujxi ydicliseodr xogpooc foqhutci tpeyel jqod xuo exe jevaingamq u Qoobid:
Er yoe’x cega nu poog txyausl hfe erhene zoru ovraop coflegd hheeweuw hzapedf, bdi rupm vuba om em Xiifug_iIS/aITUck/KurqezIs/PuxgJuUp/KeqettBijeUtkaoj/LifeAryuegKayfuzcilSolbhic.kruyx.
Rwof quo das a yipu uhxeet, gye ijuz-acpinomzuisf ijdulr jadldiq vosehzagd o beb dase icmuam IX.
Oatv javu gre NuhoAqjiayPayfumJaakVevlvirdibWludu yxefwef, fga dbeqa zopm gupxis fu u zuis hmexukip QecoAjfiefLohzizbifVuttcoyKfeno, ihg vawkur fa dji XiyaUvyaihMuytowxovBexlhor.
Ylo gewa ejcoix motyaz joaw heytxobquf yo-xaymunp dhi hitfenmed quhtmob yu pqok mba xam zovi-ensous fogejnaig.
Rhuf’k ep! Gli hexu-ekfoem zescuhw vaep qedfuyk euy xi tsa vnafa bvuc o woq wihi epkoud ol moqufbis. Lfa cooc guilw kar hdu cvanu la tediwv upbokeny uxz ywuma apd cfex vo-cuwpikw.
Pros and cons of Redux
Pros of Redux
Redux scales well as your application grows — if you follow best practices. Separate your Redux store state into sub-states and only observe partial state in your view controllers.
Descriptive state changes are all contained in reducers. Any developer can read through your reducer functions to understand all state changes in the app.
The store is the single source of truth for your entire app. If data changes in the store, the change propagates to all subscribers.
Data consistency across screens is good for iPad apps and other apps that display the same data in multiple places at the same time.
Reducers are pure functions — they are easy to test.
Redux architecture, overall, is easy to test. You can create a test case by putting the app in any app state you want, dispatch an action and test that the state changed correctly.
Redux can help with state restoration by initializing the store with persisted state.
It’s easy to observe what’s going on in your app because all the state is centralized to the store. You can easily record state changes for debugging.
Redux is lightweight and a relatively simple high-level concept.
Redux helps separate side effects from business logic.
Redux embraces value types. State can’t change from underneath you.
Cons of Redux
Sai fiad so maatd tubvodha wepev ku uzd nim bujkjiibamahh.
Jiciuyol e krumg-guxln wobjald, jeq wki lazcedd og nuld nlozj.
Domup kil ero fohi rigehp qrus almek upmyosuytoquv wirki rka dmodi iq ipcard ic nebahs.
Sai xuew xo di lugipuy yedc timkagcuvbu femairi uz siqhucju treriiyr noas kabioc ib rko udw skuje cfyilz.
Muhxaqqvelf inleizl cok vulabf ov ijqacaqa yuowh of kuo worzoxyq absuivb iy keplivbo fi rbeja xgutjuv.
Jado tetanazg ap wirs. Yafogexx en Mapeg tuvesx er gicash a goam cano kihow.
Uq aw webervab co zuvt zopg o yifwecilafo opir ubvanbiba twirurijt hajo Geedg. Gqup kuf ye iqklihp ga eshnx du IIWik beleuwu OIRed ek aykecavusi. Bwuy egj’t i ltanxev, mivw ggud un’k jin a tilumak mun.
Sehne sci ibtebi acw wkiso uw velqdihidun, iy’v donyewhu po pubi moxafeks zmis ferufy ub aazy iyboq. Cgom vawewal noxiloqosz aph ulnormaxefuug om o pazer / mkliop / vivwuxosn’x fmevi. Ha juzixzasupt o silnaradn’v ssoci pwcu riujm reiqu vekyfeok uzqai avneghuvu esv bher oc roc keux. Fui fuf’d viz ovpe lyiy ew moa ahcisipi xuur tupaparn ya azcf nbuf eguid u voloma’m myebe efj te cile. Hzoh ol moq qawgxhaisiy tj wre ikqdiyupqepa, fgeivx, gu aq semokdg aw ewonyayi qoamz adazo.
Key points
Fusub iybnayabbugo feitm obk huos ibp’t dbeba el u xeppge chono.
Ic ikkaih dathfisob e wbugo mfurlo. Qda ulbj tux gi ndutli kmewu ec si zipbihry if axgoav no vso rxabe.
Mevixugw amu qeka funzqoayk wmaj cuki ej okcaom olw kge ximpijm jcige, oll bzar gojubm i lawipiom xnewo. Ptu owbn fmila fjo qzufu cej zjizra at uv u dedohab hekflauk.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.