æã§äžå€ããŒã¿ãæäœããããšããŠãããšããäºå®ã¯ãªãã·ã§ã³ã§ãã ã¢ããªã±ãŒã·ã§ã³ã®äžå€ã®ç¶æ ã¯ãå¥ã®ãã¥ãŒãå¥ã®ãã¥ãŒãå¥ã®ãã£ã¹ãã¬ã€ã§ãã åžžã«çããŠããã¢ãã«ã䜿çšããŠããã€ã§ããã®ãã©ãããªæ圱ãååŸã§ããŸãã
-ç§ã®ååã¯Azat Razetdinovã§ããã¡ãŒã«ããã£ã¹ã¯ãã«ã¬ã³ããŒããã¹ããŒããã¢ã«ãŠã³ã管çãªã©ã®YandexããŒãœãã«ãµãŒãã¹ã代衚ããŠããŸãã èŠåŽããã«Webã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ã管çããããšã«ã€ããŠã話ãããããšæããŸãã

ã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ã¯äœã§ããïŒ ããã¯ãWebã¢ããªã±ãŒã·ã§ã³å šäœã®ã¢ãŒããã¯ãã£ã®äžå¿çãªæŠå¿µã§ãã ä»ã®ã³ã³ããŒãã³ããäŸåãããã®ã¯ãã¹ãŠããã«ä¿åãããŸãã ããšãã°ãæãæãããªãã®ã¯ãã£ã¹ãã¬ã€ã§ãããã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ãããŠã¹ããªãŒã®åœ¢ã§è¡šãããã©ãŠã¶ã«è¡šç€ºãããŸãã
ããã¯æ倧ã®éšåã§ãããå€ãã®äººã¯ãŸã ä»ã®éšåãããããšãå¿ããŠããŸãã ã¢ãã¬ã¹ããŒã®çŸåšã®URLã¯ãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ã«ãäŸåããŸãã ãŠãŒã¶ãŒãã¢ããªã±ãŒã·ã§ã³ã®ä»»æã®ããŒãžã®urlãã³ããŒããŠå人ã«éä¿¡ãããã¹ãŠãåãããã«éãããšãéåžžã«éèŠã§ãã çŸåšã®URLã¯åžžã«çŸåšã®ç¶æ ã«å¯Ÿå¿ãããããåæ ããå¿ èŠããããŸãã
ã»ãšãã©ã®å ŽåããµãŒããŒäžã®ã¢ããªã±ãŒã·ã§ã³ç¶æ ã®åæããããŸãã ã¯ã©ã€ã¢ã³ãã§å€æŽãããã¹ãŠã®ãã®ãäœããã®åœ¢ã§ãµãŒããŒäžã«ããããšãåžžã«ç¢ºèªããããšãéèŠã§ãã
ãªããžããªã«ããŒã«ã«ãªå€æŽãä¿åããŠãããããå€æŽãååŸãããå ŽåããããŸãã ãã©ãŠã¶ã«çŽæ¥ä¿åããŸãã ããã«ã¯ãå€ãã®å Žåãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ãããŒã«ã«ã¹ãã¬ãŒãžãšåæããå¿ èŠããããŸãã å®éãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ã«äŸåããå€ãã®éšåããããŸãã
ããã§åé¡ã¯äœã§ããïŒ
ååãšããŠãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ã¯ãå€ãã®ããŒã¿ãããããªãŒã§ãããããã€ãã®ãªã¹ãããªããžã§ã¯ããããã·ã¥ãããªããã£ãããŒã¿ããããŸãã 倧èŠæš¡ãªéå±€æ§é ã

åé¡ã¯ããããéå±€çã§ãããšããããšã§ã¯ãªããçããŠããããšã§ãããåžžã«å€åããŠãããšããããšã§ãã ããå Žæã§å€åãã次ã«å¥ã®å Žæã§å€åããŸãã ã©ã®ãããªåé¡ã解決ãããã§ããïŒ
ããªããé·ãéããã³ããšã³ãã«ãããªããããªãã¯ããããå€æŽãžã®æåãµãã¹ã¯ãªãã·ã§ã³ã®ãããªãã¿ãŒã³ã«ç²ŸéããŠããã§ãããã
çŸåšã®ç¶æ ãååŸãããããã³ã³ããŒãã³ãã®åæ衚瀺ã«äœ¿çšããŠãããå€æŽããµãã¹ã¯ã©ã€ãããŠãããã«å¯Ÿå¿ããŸãã
å€ããã¬ãŒã ã¯ãŒã¯ãæãåºããšãæ¬äŒŒã³ãŒãã§ã¯ãã®ããã«èŠããŸããã

ãŸããçŸåšã®ç¶æ ã䜿çšããå€æŽããµãã¹ã¯ã©ã€ãããå€æŽããšã«ããã€ãã®ã¢ã¯ã·ã§ã³ãå®è¡ããŸãã 以åã¯ãã¡ãã·ã§ããã«ã ã£ãã®ã§ã家ã®èŠçŽ ãåå¥ã«å€æŽããããçŸåšãã¡ãã·ã§ããã«ã§ããããã¬ã³ããªã³ã°å šäœãåèµ·åããŸãã
ãã®ã¢ãããŒãã«ã¯2ã€ã®åé¡ããããŸãã
ããªãŒå ã®ããŒããå€æŽããããã«ãµãã¹ã¯ã©ã€ãããå Žåãã»ãšãã©ã®å Žåãå®è¡ããŠããã¢ã¯ã·ã§ã³ãå€ãããŸãã æãå¯èœæ§ãé«ãã®ã¯ãçŸåšã®ã³ã³ããŒãã³ããã¢ããªã±ãŒã·ã§ã³ã®ããªãŒã®ç¶æ å šäœã«äŸåããŠããããäžèŠãªæäœãå€ãããããšã§ãã ãã®ããããã®å Žæã§ã¯éåžžãäœããã®æé©åãéå§ããã³ã³ããŒãã³ããŸãã¯ã¢ã¯ã·ã§ã³ãäŸåããã¢ããªã±ãŒã·ã§ã³ã¹ããŒã¿ã¹ãã£ãŒã«ãã®ã¿ãéžæããããšããŸãã
ãããããã®ã¢ãããŒãã«ãåé¡ããããŸãã
æåã§ãããè¡ãããããã°ããã®éååšããŠãããããžã§ã¯ãã§ã¯ãé ããæ©ããã©ããã§äœããå¿ãããªãã¡ã¯ã¿ãªã³ã°ããäžéšã®ãã£ãŒã«ãã«äŸåé¢ä¿ãè¿œå ããªããšç¶æ ãçºçããã³ã³ããŒãã³ãã®è¡šç€ºã«åœ±é¿ããå¯èœæ§ããããŸãã

ããã§äœãèµ·ãã£ãã®ã§ããïŒ åå¿ã¯åœŒã®ãããã£ãŒã«åçãæŽæ°ããŸããããã©ãã§ãæŽæ°ãããŸããã§ããã 倧ããªã¢ãã¿ãŒãå€æŽããããã€ãŒãå ã®å°ããªã¢ãã¿ãŒã¯ãŠãŒã¶ãŒã®ã¢ãã¿ãŒã®å€æŽã賌èªããããã®å€æŽãåãåãããèªåèªèº«ãæŽæ°ããªãã£ãããšãå€æããŸããã ããã¯ãæåãµãã¹ã¯ãªãã·ã§ã³ã®æ倧ã®ãã€ãã¹ã§ãã
ãã®å Žæã§MobXã圹ç«ã¡ãŸãã 䜿çšããã¢ããªã±ãŒã·ã§ã³ã¹ããŒã¿ã¹ãã£ãŒã«ãã«æ£ç¢ºã«ãµãã¹ã¯ãªãã·ã§ã³ãå®è£ ããŸãã
ããã瀺ãã«ã¯ãå éšããã©ã®ããã«æ©èœãããã説æããå¿ èŠããããŸãã
ãã³ã¬ãŒã¿ã䜿çšããŸãã æããŠã¯ãããŸããããã³ã¬ãŒã¿ã®å©ããåããŠæžããããã®ã¯ãã¹ãŠãã©ãããŒã®éåžžã®æ©èœã䜿çšããŠæžãããšãã§ããŸãã ãã³ã¬ãŒã¿ã¯ãæ確ããšç°¡æœãã®ããã ãã«ãããŸãã

ãã®ãããªã¯ã©ã¹ã宣èšããŸããã-人ãç·ã ãããŠã3ã€ã®ãã£ãŒã«ãã宣èšãã芳å¯å¯èœãªãã³ã¬ãŒã¿ã§ããŒã¯ããŸãã ååãå§ãããã¯ããŒã ã
MobXã«ã€ããŠè©±ããšããExcelã§é¡æšããããšã¯éåžžã«äŸ¿å©ã§ãã

芳枬å¯èœãªãã£ãŒã«ãã¯ãã»ã«å ã®çããŒã¿ã«ãããŸããã
ä»ã®æŠå¿µãèªåèªèº«ã远跡ã§ããããã«ããŸãã
Computedã¯ãå€æŽããã©ããŒããŠãããŠãŒã¶ãŒã«éç¥ããããšãã§ãããšããç¹ã§observableã«äŒŒãŠããŸãããå€ãå éšã«ä¿åãããä»ã®èŠ³å¯å¯èœãªãã£ãŒã«ãã«åºã¥ããŠèšç®ããŸãã

ãã®å Žåãååãšå§ãã¹ããŒã¹ã§é£çµããã ãã§ãã

Excelã§é¡æšããããã«ãããã¯æ°åŒãæã€ã»ã«ã§ãã ãããŸã§ã®ãšãããšãŠãç°¡åã«æããŸãã
ããã¯ããããReduxããç¥ã£ãŠããã¢ã¯ã·ã§ã³ã§ã¯ãããŸããããéåžžã«ãã䌌ãŠããŸãã

MobXã®èŠ³ç¹ã§ã¯ãã¢ã¯ã·ã§ã³ã¯åãªãé¢æ°ã§ãã ããã§ã¯ã¡ãœããã§ãããå¿ é ã§ã¯ãããŸããã ã¢ã¯ã·ã§ã³ã¯ã¯ã©ã¹ã¡ãœããã§ããå¿ èŠã¯ãããŸãããã¢ããªã±ãŒã·ã§ã³å ã®ã©ãã«ã§ãååšã§ããŸããäž»ãªããšã¯ãã¢ã¯ã·ã§ã³ãã³ã¬ãŒã¿ã§ããŒã¯ãããŠããããšã§ãã ãã®é¢æ°å ã§ã以åã«ããŒã¯ããç£èŠå¯èœãã£ãŒã«ããå€æŽã§ããŸãã
ãã¹ãŠãæ確ãªéãã¡ãœããã¯nickNameãèšå®ããŸãã
ä»ãéæ³ãå§ãŸããŸãã
MobXã®æãéèŠãªæŠå¿µã¯åå¿ã§ãã
ãããã¯èšç®ã«äŒŒãŠãããå éšã§ããã€ãã®èŠ³æž¬å¯èœãã£ãŒã«ããŸãã¯èšç®ãã£ãŒã«ãã䜿çšããŸãããå€ãè¿ããŸããã 代ããã«ãå¯äœçšããããŸãã
æãéèŠãªã®ã¯ãå ã®ããŒã¿ãå€æŽããããã³ã«åå¿ãããªã¬ãŒãå®è¡ããŸãã¯åéãããããšã§ãã ãã®å Žåãããããã§ã¯ãªããåç¹å®ã®åå¿ã«äŸåãããã®ã®ã¿ã
æãåçŽãªåå¿ã¯ãMobXã©ã€ãã©ãªã®èªåå®è¡æ©èœã§ãã

ã³ã³ãœãŒã«ã«ç¹å®ã®åŒã衚瀺ããã ãã®é¢æ°ãæž¡ãããåçŽãªèªåå®è¡ãæžããŸãããã

Excelãšã®è¯ãé¡äŒŒæ§ã¯åŸãããŸãããåå¿ã¯å€ãè¿ãããã«å¿ èŠã§ã¯ãªããäœããã®å¯äœçšããããããŸãã 倧ãŸãã«èšã£ãŠãããã¯ã»ã«å ã®å¥ã®æ°åŒã§ãã
Autorunã¯ãåŒã³åºããšããã«ãé¢æ°ãåããŠå®è¡ããåŒæ°ã§æž¡ããŸããã
ãã®é¢æ°ãå®è¡ãããšã芳å¯å¯èœãªãã£ãŒã«ãããã®å Žåã¯ãŸãnickNameã«ã¢ã¯ã»ã¹ããŸãã ãããMobXããžãã¯ã®æ©èœã§ããå®éãéåžžã®ãã£ãŒã«ãã®ä»£ããã«observableã宣èšãããšããã®ãã£ãŒã«ãã«å¯ŸããŠã²ãã¿ãŒã宣èšãããŸããã
åŒã³åºããšã芳å¯å¯èœãªãã£ãŒã«ãnickNameãããèªäœã«å¢åãèšå®ããŸãããããèªåå®è¡ã§ã©ãããããé¢æ°ã®æ°ãããªã¹ããŒãååŸããŸããã
ç§ã«ãšã£ãŠäœããå€ãã£ããšãããã®å€æŽã«ã€ããŠãã®ãªã¹ããŒã«ç¥ãããå¿ èŠããããŸãã NickNameã¯ç©ºãªã®ã§ãããã§ã¯Person fullNameã®åŒã³åºããè¡ãããŸãã ãã®ãã£ãŒã«ãã®å€æŽãç³ã蟌ãã§ããŸãã FullNameã¯èšç®ãã£ãŒã«ãã§ãããfirstNameããã³lastNameãã£ãŒã«ãã«å éšçã«ã¢ã¯ã»ã¹ããã²ãã¿ãŒã§ãã

ããã§é¢æ°ã®å®è¡ãå®äºãããã®æç¹ã§MobXã¯èªåå®è¡ã«æž¡ããé¢æ°ãnickNameãfullNameãfirstNameãlastNameã®4ã€ã®ãã£ãŒã«ãã«äŸåããŠããããšãèªèããŸãã

äŸåé¢ä¿ããªãŒã¯æ¬¡ã®ããã«ãªããŸãã æåã®åã®ç£èŠå¯èœãªãã£ãŒã«ããå€æŽãããšãèªåå®è¡ãåéãããŸãã

ç§ãã¡ã®å°ããªç·ã«ããã¯ããŒã Vasekãå°ããããšã«ãããšããŸãããã

ãã®ã¡ãœããã¯ã¢ã¯ã·ã§ã³ã§ãããããèªäœã§å²ãåœãŠæäœãå®è¡ããŸãã
ãã®æäœãåŒã³åºããšãã»ãã¿ãŒãããªã¬ãŒããããã®å éšã§ãµãã¹ã¯ã©ã€ããŒã®ãªã¹ãã調ã¹ãŠãã¹ãŠã®ãŠãŒã¶ãŒã«éç¥ããŸããå€æŽãããããäœããã®æ¹æ³ã§ç¶æ ãæ€èšŒããå¿ èŠããããŸãã

èªåå®è¡ã¯äœããå€æŽããããšããéç¥ãåãåããŸããåèµ·åããå¿ èŠããããŸãã é¢æ°ã®å®è¡ãéå§ããnickNameãã£ãŒã«ãã«ã¢ã¯ã»ã¹ããŸãã
ä»åã¯ç©ºã§ã¯ãããŸããã ããã§æ©èœãçµäºããŸãã

ç£èŠå¯Ÿè±¡ãã£ãŒã«ãã®ãªã¹ããã©ã®ããã«å€æŽããããã確èªããŠãã ããã nickNameãã£ãŒã«ãã®ã¿ã«ã¢ã¯ã»ã¹ãããããäŸåé¢ä¿ã®ãªã¹ãã«æ®ããŸãã äŸåé¢ä¿ã®ãªã¹ãã«ããä»ã®3ã€ã®ãã£ãŒã«ãããã¹ãŠé£ã³åºããŸãã æšãèŠããšããã®ããã«ãªã£ãŠããŸãã

ã³ãŒãã¯nickNameã空ã«ãªããŸã§fullNameãã£ãŒã«ãã«å°éããªãããã«èšèšãããŠãããããnickNameãå€æŽããããŸã§ãautorunã¯éåžžãfirstNameããã³lastNameãã£ãŒã«ããžã®å€æŽãç¡èŠããŸãã
åå®è¡ã§ã®åå¿ãäŸåé¢ä¿ã®ãªã¹ããåæ§ç¯ããããšãç解ããããšã¯éåžžã«éèŠã§ãã ã³ã³ããŒãã³ããŸãã¯å¯äœçšãäŸåãããã£ãŒã«ãã®ãªã¹ãã¯éçã«åéãããã®ã§ã¯ãªããäœæããã³ãŒãã«ã¯åéãããŸããã 远跡ããå¿ èŠããããã£ãŒã«ãã®é å-å®è¡äžã®ã³ãŒãã®åæã«åºã¥ããŠåçã«çµã¿ç«ãŠãããŸãã ãµãã¹ã¯ãªãã·ã§ã³ã®æå°ã»ããã¯ãå®è¡æã«åéãããå Žåã«ã®ã¿ååŸã§ããŸãã
èªåå®è¡ã ããåå¿ã®äŸã§ã¯ãããŸããã åå¿ãªãã¶ãŒããŒãããŸãã ããã¯Reactã®ãã«ããŒã§ãã
ãµã³ãã«ãReactã³ã³ããŒãã³ããšããŠæžãæãããšã次ã®ããã«ãªããŸãã

ãªãã¶ãŒããŒãã³ã¬ãŒã¿ãŒã䜿çšããŸãã ããã§ãéåžžã®ã©ãããŒã䜿çšã§ããŸãã renderã¡ãœããå ã§ãæåã«nickNameã«ã¢ã¯ã»ã¹ããŸãã 空ã®å Žåã¯ãfullNameã«ã ãŸã£ããåãããžãã¯ã å¯äžã®ããšã¯ããªãã¶ãŒããŒã䜿çšããå Žåãèªåå®è¡æ©èœãå®è¡ããªãããšã§ãã代ããã«ããµãã¹ã¯ã©ã€ããããã£ãŒã«ããå€æŽãããšãã³ã³ããŒãã³ãã®ãªãã€ã¬ã¯ããéå§ãããŸãã
ã³ã³ããŒãã³ããšãªãã¶ãŒããŒã®èªåãµãã¹ã¯ãªãã·ã§ã³ã«ãããReactã³ã³ããŒãã³ãã®åæç»ã®åæ°ãåçã«æå°éã«æããããšãã§ããŸãã

renderã¡ãœããã®æåã«ãã§ãã¯ããäœããã®ãã©ã°ãããå Žåããã°ãã°èŠ³å¯å¯èœãªã³ãŒãããããŸãã 倱æããå Žåã¯ãåã«nullãè¿ããŸãã ããã§React Magicãæ¬åœã«åœ¹ç«ã¡ãŸãã å€æŽãåœã§ããéãããªãã¶ãŒããŒã¯ãå€ãã®ã³ãŒããèšè¿°ãããŠãã以äžã§äœ¿çšããããã£ãŒã«ããžã®å€æŽãç¡èŠããŸãã ãã ãããã©ã°ãç¹ç¯ãããšããã«ã次ã®ã¬ã³ãã©ãŒã§æ¬¡ã®ã³ãŒããå®è¡ãããããã§äœ¿çšããããã£ãŒã«ããžã®å€æŽããµãã¹ã¯ã©ã€ããããŸãã
ReactãããŠã¹ãªãã¬ãŒã·ã§ã³ãç¯çŽããå ŽåãMobXã¯ããŒãã£ã«ããŠã¹ãªãã¬ãŒã·ã§ã³ãç¯çŽããŸãã ä»®æ³äœå® ã§ãåæç»ãå°ãªãã»ã©ãã¢ããªã±ãŒã·ã§ã³ã¯é«éã«ãªããŸãã
MobXã«çµã¿èŸŒãŸããŠããå¥ã®æé©åãèšç®ãã£ãã·ã¥ã«ã€ããŠèª¬æããŸãã

ããã§ãfullNameã¯åçŽã§ãããäžè¬çã«éåžžã«è€éã§ãïŒããã€ãã®ãã£ã«ã¿ãŒãåæžãè€éãªèšç®ã åé¡ãçºçããŸãïŒæ¯åãã®ã²ãã¿ãŒã䜿çšããå Žåãåãæäœãå®è¡ãããã³ã«ãããã®æäœããã¹ãŠäžå¿ èŠã«å®è¡ããå¿ èŠã¯ãããŸãããïŒ ãã£ãã·ã¥ã«å ¥ããããªãã®ã¯ãªãã§ããïŒ

èšç®ã䜿çšããããŒã¿ãå€æŽããããŸã§ãèšç®ã¯åããŠèšç®ãå®è¡ããå€ããã£ãã·ã¥ã«å ¥ãã誰ããããã«ã¢ã¯ã»ã¹ãããã³ã«ãããã«ãã£ãã·ã¥ããå€ãäžããŸãã

ãã ããnickNameãã£ãŒã«ããèšå®ããfullNameããèªåç»é²è§£é€ãããšããã®æç¹ã§fullNameã¯ãµãã¹ã¯ã©ã€ããŒããªããªã£ãããšãèªèãããšããã£ãã·ã¥ãç Žæ£ããŸãããã£ãã·ã¥ã¯ãã¬ããŒãžã³ã¬ã¯ã¿ãŒã«ãã£ãŠåéãããéåžžã®ã²ãã¿ãŒã®ããã«æ©èœããŸãã
ãã£ãã·ã³ã°ã¯åžžã«ãµãã¹ã¯ã©ã€ãã®å¯çšæ§ã«äŸåãããµãã¹ã¯ã©ã€ãã¯åžžã«è€æ°ã«ãªãå ŽåããããŸãã
ãã®ã¢ãããŒãã§éåæããŒã¿ãæäœããæ¹æ³ã®å°ããªäŸã
æåã§ããŒãã¡ãœãããèµ·åãããã©ã°isLoading TrueãŸãã¯Falseãå®è¡ã§ããŸãããMobXã«ã¯fromPromiseãšãããã«ããŒããããŸãã

ç¹å®ã®ãã£ãŒã«ãã宣èšããfromPromiseãã«ããŒã§éåææäœãã©ãããããšããã®ãã£ãŒã«ãã«2ã€ã®ãµããã£ãŒã«ãïŒç¶æ ãšå€ïŒã衚瀺ãããŸãã
Reactã³ã³ããŒãã³ãã§ã¯ãæåã«ãã®ç¶æ ãä¿çäžã§ããããšã確èªã§ããŸãã 次ã«ãããçš®ã®è² è·ã瀺ããŸãã ãã£ã±ãã«ãªã£ãããå€ãã£ãŒã«ãã«æ»ããã³ã³ããŒãã³ããããã«æç»ããŸãã
åèšãããã«MobXã

ãã§ã«èŽè¡ãã質åããããŸãã ç§ã¯ãã®ç·ãReduxmanãšåŒã³ãŸããããã¯Reduxã§å€ãã®ã³ãŒããæžãã人ã§ãã 圌ã¯ã©ããªè³ªåãããŠããŸããïŒ

ãããããã¿ããªãã£ã«ã€ããŠã¯ã©ãã§ããïŒ ããããã¡ãœããã䜿çšããŠã¢ãã«ãã£ãŒã«ããçŽæ¥å€æŽã§ããŸããïŒ ããŠãã€ããžã¯ã§ã¯ãããŸããã
ããããã¿ã€ã ãã©ãã«ã¯ã©ãã§ããïŒ ã¡ãœãããåããã¢ãã«ã¯å¿ èŠãããŸããããå ã«æ»ããããçŽãããã®ä»ã®ããããããšãæ¯æŽã§ããããã«ãåçŽãªãã¬ãŒã³ãªJavaScriptãªããžã§ã¯ããå¿ èŠã§ãã
ãŠãŒã¶ãŒãå®è¡ããã¢ã¯ã·ã§ã³ãåçŸã§ããããã«ãç§ãæ¢ã«æ £ããŠãããæ°ã«å ¥ãã®éçºããŒã«ã¯ã©ãã§ããïŒ
Reduxã«ã€ããŠå°ã説æããŸãã 圌ãéçºè ã®é ã§è¡ã£ãäž»ãªå€æŽã

圌ã¯OOPããé¢æ°åããã°ã©ãã³ã°ã«ç§»è¡ããŸããã ã¢ãã«ã®ä»£ããã«ãäžå€ã®æ§é ã䜿çšããå§ããŸããã ã¡ãœããã®ä»£ããã«ãã¢ã¯ã·ã§ã³ãšãªãã¥ãŒãµãŒããããŸãã éåžžã®æ¥ç¶ã®ä»£ããã«ãã¢ãã«éã®ãªã³ã¯ã«æ£èŠåãšã»ã¬ã¯ã¿ãŒãè¿œå ãããŸããã
ãããŠãããã¯éåžžã«ã¯ãŒã«ã§ãReduxã倧奜ãã§ããããããæ°ã«ãªãç¹ã1ã€ãããŸããå€ãã®å®åæãæã§æžããªããã°ãªããªãããšããããããããŸãã äœããã®çš®é¡ã®ã¢ã¯ã·ã§ã³ãè¿œå ããå¿ èŠãããå Žåãã¢ã¯ã·ã§ã³ãã¬ãã¥ãŒãµãŒããããŸããå€ãã®å Žåãã»ã¬ã¯ã¿ãŒããŸã å¿ èŠã§ãã ãããŠãç§ã¯ç¿ã®ä»äºãããŠãããšããæèŠããããŸãã
ReduxãMobXãšã©ãéãã®ãèãå§ãããšããç§ã¯ãã®ãããªã¢ãããžãŒãæã¡ãŸããã

誰ãããã®æŒ«ç»ã奜ãã§ããïŒ ãããŠãè¥ãäžä»£ãèŠãŠãã挫ç»ã¯ã©ãã§ããïŒ åœŒãã¯ãã®ãããªãã®ã§ãã

éãã¯äœã§ããïŒ ãã®ããã«æãããããã ãšãžã§ãªãŒãã¯ããã¬ãŒã ãåãããããããåå¥ã«æããã

äœã«ã䌌ãŠããŸãããïŒ Reduxã¢ããªã±ãŒã·ã§ã³ã®äžå€ã¹ãã¢ã æã§äœæããã€ã³ããªã³ãããããã³ã«ãäžå€ãŸãã¯Object.assignãŸãã¯spreadãªãã¬ãŒã¿ã©ã€ãã©ãªã䜿çšããŸãã ã¢ããªã±ãŒã·ã§ã³ã®çŸåšã®ç¶æ ãæã§æããã³ã«ã ããŒã«ããã¯ããå¿ èŠãããå Žåã¯ãååŸããŠããŒã«ããã¯ããŸãã ããã¯ãã¹ãŠã¯ãŒã«ã§ãå€ãã®ã³ãŒãã®ã¿ãååŸãããŸãã ã³ãŒããæžãã®ã¯å¥œãã§ã¯ãªããåé€ããã®ã奜ãã§ãã ã³ãŒãã¯æªã§ãã æéã®ã³ãŒãã¯ãå®è¡ãããªãã³ãŒãã§ãã
ãããŠãæ°ãã挫ç»ã¯ãã®ããã«æããŸãã

3次å ã¢ãã«ãæç»ããããã°ã©ã ã§å転ãããã¬ãŒã ãåããéã«å転ããããã¬ãŒã ãåããŸãã 圌ãã¯çããŠããã¢ãã«ãå¶åŸ¡ããããããåçŽã«ã¹ã¯ãªãŒã³ã«æ圱ããŸãã
æã§äžå€ããŒã¿ãæäœããããšããŠãããšããäºå®ã¯ãªãã·ã§ã³ã§ãã ã¢ããªã±ãŒã·ã§ã³ã®äžå€ã®ç¶æ ã¯ãå¥ã®ãã¥ãŒãå¥ã®ãã¥ãŒãå¥ã®ãã£ã¹ãã¬ã€ã§ãã åžžã«çããŠããã¢ãã«ã䜿çšããŠããã€ã§ããã®ãã©ãããªæ圱ãååŸã§ããŸãã
ãã®æ¹æ³ã瀺ããŸãããã MobXã®äœæè ã¯ããã®ãããªå¥åã®éšåãäœæããŠããŸãã ããã¯ãã¢ããªã±ãŒã·ã§ã³ã®äœææ¹æ³ã決å®ããããã説åŸåã®ããã¢ãããŒãã§ãããèŠè¿ãã«å€ãã®å©ç¹ããããŸãã
å°ããªã¹ãã¢ãäœæããŠãTodoã¯ã©ã¹ã宣èšããŸãããããã®ããã«ãã¢ãã«ã¡ãœãããæã€åãã«ããŒã䜿çšããŸãã 空ã®éã«ã

ã¿ã€ãã«ãè¿œå ããŸãã
ããã§ã¯ããããæååã§ããããšã宣èšããŸãã
ãªãã·ã§ã³ã®ããŒã«ãã£ãŒã«ãisCompletedãè¿œå ããŸãã ã¡ãªã¿ã«ãçãæžãæ©äŒããããŸãã äœããã®çš®é¡ã®ããªããã£ããå²ãåœãŠããšãmobx-state-treeã¯ããããããã©ã«ãå€ãæã€ãªãã·ã§ã³ã®ããªããã£ããã£ãŒã«ãã§ããããšãç解ããŸãã

åç §ãè¿œå ããŸãã ããã¯ããã©ã«ããŒãä»ã®ãªããžã§ã¯ãã®IDãå«ãããšãæå³ããŸãããmobx-state-treeã¢ãã«ãäœæãããšãããã®IDã¯ç¹å®ã®ã¹ãã¢ãããã®ãªããžã§ã¯ããååŸãããã®ãã£ãŒã«ãã«é 眮ããŸãã å°ãåŸã§äŸã瀺ããŸãã


ãã¹ãŠã®éæ³ãæ©èœããã«ã¯ãFolderã¯ã©ã¹ã宣èšããå¿ èŠããããŸãããã®ã¯ã©ã¹ã«ã¯ãtypes.identifieråã®idãå¿ èŠã§ãã ããã¯ããªã³ã¯ãã¹ãã¢ãªããžã§ã¯ãã«èå¥åã§é¢é£ä»ããããã§ãã

ã¡ã€ã³ã«ãŒãã®TodoStoreã宣èšããŸããããã«ã¯ãtodosãšfolderã®2ã€ã®é åããããŸãã ããã§ã¯ãtypes.arrayã®äœ¿çšæ¹æ³ã確èªã§ããŸããã¯ã©ã¹ãåŒæ°ãšããŠæž¡ããšãMobXã¯ãã®ã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹é åã§ããããšãç解ããŸãã

ã²ãã¿ãŒã宣èšãããšãåã«èŠãããã«ãMobXã®çšèªããèªåçã«èšç®ãããŸãã ããã«ã¯ãå®äºããTodosã²ãã¿ãŒããããŸããããã¯ãå®äºãããã¹ãŠã®Todoã®ãªã¹ããåã«è¿ãã ãã§ãã ãã£ãã·ã¥ãããå°ãªããšã1ã€ã®ãµãã¹ã¯ã©ã€ããŒãããéããåžžã«ãã£ãã·ã¥ãããå€ãè¿ããŸãã ãã®ããã«æžãããšãè€éãªåŒãæžãããšãæããªãã§ãã ãããããã¯ãã¹ãŠãã£ãã·ã¥ãããŸãã

ãããã¢ã¯ã·ã§ã³ã®äœææ¹æ³ã§ãã 宣èšã®æåã®ãªããžã§ã¯ãã¯ããããã£ã§ããèšç®ããã2çªç®ã®ãªããžã§ã¯ãã¯ã¢ã¯ã·ã§ã³ããªã¹ãããŸãã ããã§ã¯ãããããæ¢ã«å®£èšããå¿ èŠã¯ãããŸãããmobx-state-treeã¯ããã©ã«ãã§ã2çªç®ã®ãªããžã§ã¯ãã«æž¡ããã®ã¯ãã¹ãŠã¢ã¯ã·ã§ã³ã§ãããšä¿¡ããŠããŸãã

ã¹ãã¢ãäœæããŠã¿ãŸãããã ããŒã¿ããããŸããããšãã°ããµãŒããŒããã®ãã®ã§ãæ£èŠåããã圢åŒã§ããããã©ã«ããŒã«1ãããããã©ã«ããŒãªã¹ãã«èå¥å1ã®ãªããžã§ã¯ãããããšããŸãã

äœæã䜿çšããŸãã
æåã®è¡-ãã¹ãŠã¯åé¡ãããŸãããtodoãªããžã§ã¯ãã®titleãã£ãŒã«ãã䜿çšããŸãã
2è¡ç®ã¯ãã§ã«éæ³ã§ãïŒãã©ã«ããŒã¯åç §ãšããŠå®£èšãããŠãããããã¢ãã«ã®äœææã«MobXã¯ãŸããã©ã«ããŒããã©ã«ããŒé åã«å ¥ããtodoã¢ãã«ã«åç §ã«ãã£ãŠãèå¥åã«ãã£ãŠããã®ãªããžã§ã¯ããžã®ãªã³ã¯ãè¿œå ããŸãã Reduxã®ã»ã¬ã¯ã¿ãŒã¯ãããã§ãã®ãŸãŸäœ¿çšã§ããŸãã ãªã³ã¯ã®ãã¹ãããããã£ãŒã«ããåç §ã«å®å šã«ã¢ã¯ã»ã¹ã§ããŸãã ãããŠãããã¯æ©èœããŸããã»ã¬ã¯ã¿ãŒãä»ã®ãããããžã®ãããç¶æ ãªãã§ã³ã³ããŒãã³ããæžãããšã¯éåžžã«äŸ¿å©ã§ãã
ããçš®ã®3Dã¢ãã«ãäœæããŸããã å®è¡ããŠã¿ãŸãããã ã«ã¡ã©ãã¢ãŒã¿ãŒã

ãŸããã¢ãã«ã«å ¥ããããŒã¿ãåãæ»ãããšããŸãã ããã«ã¯getSnapshotãã«ããŒããããŸãã ã¢ãã«ãããã«è»¢éãããã¹ãŠã®ç·šéè ã奜ãããã«ãéåžžã®JSãªããžã§ã¯ãã®åœ¢åŒã§ã¹ãããã·ã§ãããååŸããŸãã åä¿¡ããåä¿¡ããŸããããç§ã®ã¢ãã«ã¯çµ¶ããå€åããŠããŸããã©ã®ããã«å€æŽã«ãµãã¹ã¯ã©ã€ãããŸããïŒ

éåžžã«ç°¡åïŒã¢ãã«å ã®ä»»æã®ãã£ãŒã«ããå€æŽããããã«ãµãã¹ã¯ã©ã€ãã§ããonSnapshotãã«ããŒãããããã©ã¡ãŒã¿ãŒãšããŠãçæããæ°ããã¹ãããã·ã§ãããåžžã«æž¡ããŸãããããã§ã¯ãªããããã§ãªãå Žåã¯æ¯åæ°ãããªããžã§ã¯ããçæããã®ã¯æããªããšã§ãã Reactãšåæ§ã«ãäžå€ã䜿çšããŸãã
äžéšã®éšåãå€æŽãããå Žåã圌ã¯ããããåå©çšããæ§é å ±æã¡ã«ããºã ãéå§ããŸãã
å€æŽããããããæ°ãããªããžã§ã¯ããäœæããŸãã

ã¿ã€ã ãã©ãã«ã®äœãæ¹ã¯ïŒ å±¥æŽãèŠãŠãããçš®ã®ã¹ãããã·ã§ãããã¢ãã«ã«é©çšããããšæããŸãã applySnapshotãã«ããŒããã¹ã¢ãã«ããã¹ãã¹ãããã·ã§ããããããŸãã éä¿¡ãããã®ãšçŸåšã¢ãã«ã«ãããã®ãæ¯èŒããå·®åãåããå€æŽãããéšåã®ã¿ãæŽæ°ããŸãã
åæã«ãèå¥åãäžèŽããå Žåãã¢ãã«ãåå©çšããŸãã id = 1ã®ãã©ã«ããŒãã¢ãã«å ã«ããå Žåãid = 1ã®ãã©ã«ããŒãã¹ãããã·ã§ããã«è»¢éãããŸãããäžæžãããããšããã®ã§ã¯ãªãããã©ã«ããŒèªäœã®ããŒã¿ãå€æŽãããå Žåã¯æŽæ°ãããŸãã
èå¥åãæ£ããèšå®ããå Žåãã¢ãã«å ã®ã€ã³ã¹ã¿ã³ã¹ã¯äžæžããããŸããã
ãããããã©ã€ãã¢ãã«ãšã¹ãããã·ã§ãããã©ã®ããã«æ©èœãããã®æãå°è±¡çãªã€ã©ã¹ãã§ãããã
çããŠããã¢ãã«ãããããã€ã§ãã¹ãããã·ã§ãããååŸã§ããŸãã
æåŸã«ãç¹ã«ç·šéè ã«ãšã£ãŠã®ããŒãã¹ã Reduxãæäœããããã®ã¢ããã¿ãŒããããŸãã , Redux style, store mobx-state-tree store reduxStore asReduxStore.

ReduxDevtools, connectReduxDevtools, , store mobx-state-tree, .

- immutable-. -, , , . - , .
. , . Todo.folder.parent , . , , .
, . , React. , . â Redux Store Redux Devtools.

, MobX â React, . , :
- MobX
- mobx-state-tree
- Becoming fully reactive: an in-depth explanation of MobX
- MobX vs. Redux Performance
- An artificial example where MobX really shines and Redux is not really suited for it
.