ãã®èšäºã§ã¯ãå€æ°éã®è¿œè·¡äŸåé¢ä¿ãèªååãããã®å€ãå¹æçã«æŽæ°ããããã«èšèšããããååãæœè±¡åã«ã€ããŠèªè ã«çŽ¹ä»ããŸãã Atomã¯ä»»æã®èšèªã§å®è£ ã§ããŸãããèšäºã®äŸã¯JavaScriptã§èšè¿°ãããŸãã
泚æïŒèªæžã¯è³ã®è±èŒãããªããŒã®æ»æããªãã¡ã¯ã¿ãªã³ã°ã®ç ãã¬å€ãåŒãèµ·ããå¯èœæ§ããããŸãã
åçŽãªãã®ããè€éãªãã®ãŸã§
ãã®ç« ã§ã¯ãããªãåçŽãªã¢ããªã±ãŒã·ã§ã³ã®å žåçãªé²åã«ã€ããŠç°¡åã«èª¬æããèªè ãåŸã ã«ã¢ãã ã®æŠå¿µã«å°ããŸãã
ãŸãããã®ãããªåçŽãªã¿ã¹ã¯ãæ³åããŠã¿ãŸãããããŠãŒã¶ãŒã«ãŠã§ã«ã«ã ã¡ãã»ãŒãžãæžã蟌ãå¿ èŠããããŸãã ãããå®è£ ããããšã¯é£ãããããŸããïŒ
this.$foo = {} $foo.message = ', !' $foo.sayHello = function(){ document.body.innerHTML = $foo.message } $foo.start = function(){ $foo.sayHello() }
ããããååã§ãŠãŒã¶ãŒã«é£çµ¡ããã®ã¯è¯ãããšã§ãã ãŠãŒã¶ãŒåãlocalStorageã«ä¿åãããŠããå Žåãå®è£ ã¯ããå°ãè€éã«ãªããŸãã
this.$foo = {} $foo.userName = localStorage.userName $foo.message = ', ' + $foo.userName + '!' $foo.sayHello = function(){ document.body.innerHTML = $foo.message } $foo.start = function(){ $foo.sayHello() }
ãã ããåæåäžã«userNameãšã¡ãã»ãŒãžã®èšç®ãè¡ãããŸãããsayHelloãåŒã³åºããããŸã§ã«ãã®ååããââã§ã«å€æŽãããŠããå Žåã¯ã©ãã§ããããïŒ ããŸãè¯ããªãå€ãååã§åœŒã«æšæ¶ããããšãããããŸãã ãããã£ãŠãå®éã«è¡šç€ºããå¿ èŠãããå Žåã«ã®ã¿ã¡ãã»ãŒãžãèšç®ãããããã«ã³ãŒããæžãçŽããŸãããã
this.$foo = {} $foo.userName = function( ){ return localStorage.userName } $foo.message = function( ){ return ', ' + $foo.userName() + '!' } $foo.sayHello = function(){ document.body.innerHTML = $foo.message() } $foo.start = function(){ $foo.sayHello() }
ã¡ãã»ãŒãžãšuserNameãã£ãŒã«ãã®ã€ã³ã¿ãŒãã§ãŒã¹ãå€æŽããªããã°ãªããªãããšã«æ³šæããŠãã ãã-ãããã¯å€èªäœãä¿åããã®ã§ã¯ãªããããããè¿ãé¢æ°ãä¿åããŸãã
è«æ1ïŒã€ã³ã¿ãŒãã§ãŒã¹ãå€æŽããéã«ãèªåèªèº«ãä»ã®éçºè ãéå±ãªãªãã¡ã¯ã¿ãªã³ã°ã«é¥ããªãããã«ãããã«å éšå®è£ ãèªç±ã«å€æŽã§ããã€ã³ã¿ãŒãã§ãŒã¹ã䜿çšããŠã¿ãŠãã ããã
Object.definePropertyã䜿çšããŠé¢æ°åŒã³åºããé衚瀺ã«ã§ããŸã ã
this.$foo = {} Object.defineProperty( $foo, "userName", { get: function( ){ return localStorage.userName } }) Object.defineProperty( $foo, "message", { get: function( ){ return ', ' + $foo.userName + '!' } }) $foo.sayHello = function(){ document.body.innerHTML = $foo.message } $foo.start = function(){ $foo.sayHello() }
ãã ãã次ã®çç±ããæ瀺çãªé¢æ°åŒã³åºãããå§ãããŸãã
* IE8ã¯ãdomããŒãã®Object.definePropertyã®ã¿ããµããŒãããŸãã
*é¢æ°ã¯ã$ foo.titleïŒ 'HelloïŒ'ïŒ.UserNameïŒ 'Anonymous'ïŒã®åœ¢åŒã®ãã§ãŒã³ã«é 眮ã§ããŸãã
*é¢æ°ã¯ã©ããã«ã³ãŒã«ããã¯ãšããŠæž¡ãããšãã§ããŸãïŒ$ foo.userName.bindïŒ$ fooïŒ-ããããã£å šäœã転éãããŸãïŒã²ãã¿ãŒãšã»ãã¿ãŒã®äž¡æ¹ïŒã
*ãã£ãŒã«ãã®é¢æ°ã¯ãã°ããŒãã«èå¥åããæ€èšŒãã©ã¡ãŒã¿ãŸã§ãããŸããŸãªè¿œå æ å ±ãä¿åã§ããŸãã
*ååšããªãããããã£ã«ç®ãåãããšãæé»çã«undefinedãè¿ãã®ã§ã¯ãªããäŸå€ãçºçããŸãã
ããããã¡ãã»ãŒãžã衚瀺ããåŸã«ãŠãŒã¶ãŒåãå€ãã£ããã©ãããŸããïŒ æ°žä¹ ã«ããã®ç¹ã远跡ããŠã¡ãã»ãŒãžãåæç»ããå¿ èŠããããŸãã
this.$foo = {} $foo.userName = function( ){ return localStorage.userName } $foo.message = function( ){ return ', ' + $foo.userName() + '!' } $foo._sayHello_listening = false $foo.sayHello = function(){ if( !$foo._sayHello_listening ){ window.addEventListener( 'storage', function( event ){ if( event.key === 'userName' ) $foo.sayHello() }, false ) this._sayHello_listening = true } document.body.innerHTML = $foo.message() } $foo.start = function(){ $foo.sayHello() }
ãããŠãããã§ã²ã©ã眪ãç¯ããŸãã-sayHelloã¡ãœããã®å®è£ ã¯ãçªç¶ãuserNameããããã£ã®å éšå®è£ ãç¥ã£ãŠããŸãïŒå€ã®ååŸå ãç¥ã£ãŠããŸãïŒã äŸã§ã¯ããããããããããã«è¿ãã«ããããšã«æ³šæããŠãã ããã å®éã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ããã®ãããªã¡ãœããã¯ããŸããŸãªãªããžã§ã¯ãã«ãããã³ãŒãã¯ããŸããŸãªãã¡ã€ã«ã«ãããããŸããŸãªäººã ã«ãã£ãŠãµããŒããããŸãã ãããã£ãŠã1ã€ã®ããããã£ããããªãã¯ã€ã³ã¿ãŒãã§ã€ã¹ãä»ããŠå¥ã®ããããã£ã®å€æŽããµãã¹ã¯ã©ã€ãã§ããããã«ããã®ã³ãŒããæžãæããå¿ èŠããããŸãã ã³ãŒããé床ã«è€éã«ããªãããã«ãjQueryã®pub / subå®è£ ã䜿çšããŸã ã
this.$foo = {} $foo.bus = $({}) $foo._userName_listening = false $foo.userName = function( ){ if( !this._userName_listening ){ window.addEventListener( 'storage', function( event ){ if( event.key !== 'userName' ) return $foo.bus.trigger( 'changed:$foo.userName' ) }, false ) this._userName_listening = true } return localStorage.userName } $foo._message_listening = false $foo.message = function( ){ if( !this._message_listening ){ $foo.bus.on( 'changed:$foo.userName', function( ){ $foo.bus.trigger( 'changed:$foo.message' ) } ) this._message_listening = true } return ', ' + $foo.userName() + '!' } $foo._sayHello_listening = false $foo.sayHello = function(){ if( !this._sayHello_listening ){ $foo.bus.on( 'changed:$foo.message', function( ){ $foo.sayHello() } ) this._message_listening = true } document.body.innerHTML = $foo.message() } $foo.start = function(){ $foo.sayHello() }
ãã®å Žåãããããã£éã®éä¿¡ã¯åäžã®ãã¹$ foo.busãä»ããŠå®è£ ãããŸãããåã ã®EventEmitterãæ£åšããããšããããŸãã ååãšããŠãåãã¹ããŒã ã¯æ¬¡ã®ããã«ãªããŸããããããããã£ãå¥ã®ããããã£ã«äŸåããå Žåã¯ãã©ããã§ãã®å€æŽããµãã¹ã¯ã©ã€ãããå¿ èŠããããå€æŽããå Žåã¯ãå€æŽã«é¢ããéç¥ãéä¿¡ããå¿ èŠããããŸãã ãŸããããããã£å€ã®è¿œè·¡ãäžèŠã«ãªã£ãå Žåããã®ã³ãŒãã§ã¯ç»é²è§£é€ãªãã·ã§ã³ã¯ãŸã£ããæäŸãããŸããã ã°ãªãŒãã£ã³ã°ã¡ãã»ãŒãžã§ãŠãŒã¶ãŒåã衚瀺ããã衚瀺ããªããã®ç¶æ ã«å¿ããŠãshowNameããããã£ãå°å ¥ããŸãããã ãã®ãããªããªãå žåçãªåé¡ã®ã¹ããŒãã¡ã³ãã®æ©èœã¯ãshowName = 'false'ã®å Žåãã¡ãã»ãŒãžããã¹ããuserNameã®å€ã«äŸåããªãããããã®ããããã£ããµãã¹ã¯ã©ã€ãããªãããšã§ãã ããã«ã以åã«showName = 'true'ããã£ãããããã§ã«ãµãã¹ã¯ã©ã€ãããŠããå ŽåãshowName = 'false'ãåãåã£ãåŸãuserNameãããµãã¹ã¯ã©ã€ãã解é€ããå¿ èŠããããŸãã ãããŠã人çããŸã£ãã楜åã®ããã«èŠããªãããã«ãå¥ã®èŠä»¶ãè¿œå ããŸããlocalStorageããããã£ããååŸããå€ã¯ãå床觊ããªãããã«ãã£ãã·ã¥ããå¿ èŠããããŸãã å®è£ ã¯ã以åã®ã³ãŒããšã®é¡æšã«ããããã®èšäºã§ã¯æ¢ã«ããªã¥ãŒã ã倧ãããããããå°ãã³ã³ãã¯ããªæ¬äŒŒã³ãŒãã䜿çšããŸãã
property $foo.userName : subscribe to localStorage return string from localStorage property $foo.showName : subscribe to localStorage return boolean from localStorage property $foo.message : subscribe to $foo.showName switch test $foo.showName when true subscribe to $foo.userName return string from $foo.userName when false unsubscribe from $foo.userName return string property $foo.sayHello : subscribe to $foo.message put to dom string from $foo.message function start : call $foo.sayHello
ããã§ã¯ãæ å ±ã®éè€ãé¡èã§ããå®éã«ããããã£å€ãååŸãã以å€ã«ããã®å€æŽããµãã¹ã¯ã©ã€ãããå¿ èŠããããŸããäžéšã®ããããã£ã®å€ãäžèŠã§ããããšãå€æããããå察ã«ããã®å€æŽããµãã¹ã¯ã©ã€ã解é€ããŸãã ããã¯éåžžã«éèŠã§ãã圱é¿ãåããŠããªãããããã£ããæéå ã«ç»é²ã解é€ããªããšãã¢ããªã±ãŒã·ã§ã³ãããè€éã«ãªããåŠçãããããŒã¿ã®æ°ãå¢ãããšãå šäœçãªããã©ãŒãã³ã¹ããŸããŸãäœäžããããã§ãã
ããŒãŒ2ïŒåœ±é¿ã®ãªãäŸåé¢ä¿ãæéå ã«ãµãã¹ã¯ã©ã€ã解é€ããŸããããããªããšãé ããæ©ããã¢ããªã±ãŒã·ã§ã³ã®é床ãäœäžãå§ããŸãã
äžèšã®ã¢ãŒããã¯ãã£ã¯ãã€ãã³ãé§ååãšåŒã°ããŸãã ãããŠãããã¯ããã«ã²ã©ããªãã·ã§ã³ã§ã-ããäžè¬çãªã±ãŒã¹ã§ã¯ããµãã¹ã¯ãªãã·ã§ã³ããµãã¹ã¯ã©ã€ã解é€ãããã³å€ãèšç®ããããã€ãã®æ¹æ³ããããžã§ã¯ãã®ããŸããŸãªå Žæã«æ£åšããŠããŸãã ã¿ã€ã ãªãŒãªãµãã¹ã¯ãªãã·ã§ã³ãšãµãã¹ã¯ãªãã·ã§ã³ãæåã§ç£èŠããå¿ èŠããããããã€ãã³ãé§ååã¢ãŒããã¯ãã£ã¯éåžžã«è匱ã§ãããŸãã人ã¯æ zyãªçãç©ã§ãããããŸã泚æãæã£ãŠããŸããã ãããã£ãŠãæè¯ã®è§£æ±ºçã¯ãããã°ã©ããŒããã€ãã³ããé åžããã¡ã«ããºã ãé ãããšã«ããããã¥ãŒãã³ãã¡ã¯ã¿ãŒã®åœ±é¿ãæå°éã«æããããšã§ããããã«ãããããã°ã©ããŒã¯ä»ã®ãŠãŒã¶ãŒããã®ããŒã¿ã®ååŸæ¹æ³ã®èª¬æã«éäžã§ããŸãã
æäœéå¿ èŠãªäŸåé¢ä¿æ å ±ã®ã¿ãæ®ããŠãã³ãŒããåçŽåããŸãããã
property userName : return string from localStorage property showName : return boolean from localStorage function $foo.message : switch test $foo.showName when true return string from $foo.userName when false return string property $foo.sayHello : put to dom string from $foo.message function start : call $foo.sayHello
èŠæå¿ã®åŒ·ãèªè ã¯ãæåã®ãµãã¹ã¯ãªãã·ã§ã³/ãµãã¹ã¯ã©ã€ã解é€ãåãé€ããåŸãããããã£ã®èª¬æããããããçŽç²ãªæ©èœãã§ããããšã«æ°ã¥ãããšæãããŸãã ãããŠå®éã FRP ïŒFunctional Reactive ParadigmïŒãå ¥æããŸããã åçšèªãããã«è©³ããèŠãŠã¿ãŸãããã
æ©èœ-åå€æ°ã¯ãä»ã®å€æ°ã®å€ã«åºã¥ããŠå€ãçæããé¢æ°ãšããŠèšè¿°ãããŸãã
ãªã¢ã¯ãã£ã-1ã€ã®å€æ°ãå€æŽãããšãããã«äŸåãããã¹ãŠã®å€æ°ã®å€ãèªåçã«æŽæ°ãããŸãã
ãã©ãã€ã -ããã°ã©ããŒã¯ãã¢ããªã±ãŒã·ã§ã³ã®æ§ç¯ã®ååãç解ããåãå ¥ããããã«å°ãæ°ãé ãå¿ èŠããããŸãã
ã芧ã®ãšãããäžèšã®ãã¹ãŠã¯å€æ°ãšãããã®éã®äŸåé¢ä¿ãäžå¿ã«å±éããŠããŸãã ãã®ãããªfrpå€æ°ããååããšåŒã³ããã®äž»ãªç¹æ§ãè¿°ã¹ãŸãã
1.ã¢ãã ã¯ãããèªäœã«å€ã1ã€ã ãä¿åããŸãã ãã®å€ã¯ãããªããã£ããŸãã¯äŸå€ãªããžã§ã¯ããå«ãä»»æã®ãªããžã§ã¯ãã®ããããã§ãã
2.ã¢ãã ã¯ãä»»æã®æ°ã®äžéé¢æ°ãä»ããŠä»ã®ã¢ãã ã«åºã¥ããŠå€ãèšç®ããããã®é¢æ°ãæ ŒçŽããŸãã å®è¡äžã«ä»ã®ã¢ãã ãžã®ã¢ããŒã«ãç£èŠããããããã¢ãã ã¯åžžã«ãä»ã®ã©ã®ååããã®ç¶æ ã«åœ±é¿ããããããã³ã©ã®ååãããã«äŸåãããã®ç¶æ ã«é¢ããææ°æ å ±ãä¿æããŸãã
3.ã¢ãã ã®å€ãå€æŽããå Žåãããã«äŸåãããã®ã¯ã«ã¹ã±ãŒãã§æŽæ°ããå¿ èŠããããŸãã
4.äŸå€ã¯ãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ã®äžè²«æ§ã«éåããŠã¯ãªããŸããã
5.ã¢ãã ã¯ãåœä»€åç°å¢ãšç°¡åã«çµ±åããå¿ èŠããããŸãã
6.ã»ãšãã©ãã¹ãŠã®ã¡ã¢ãªã¹ããããã¢ãã ã«ã©ãããããŠãããããã¢ãã ã®å®è£ ã¯å¯èœãªéãé«éãã€ã³ã³ãã¯ãã«ããå¿ èŠããããŸãã
ã¢ãã ã®å®è£ ã®åé¡
1.äŸåé¢ä¿ãææ°ã®ç¶æ ã«ä¿ã€
1ã€ã®ååã®å€ãèšç®ãããšãã«ãå¥ã®ååã®å€ãå¿ èŠãªå Žåãæåã®ååã2çªç®ã®ååã«äŸåããŠãããšç¢ºä¿¡ãæã£ãŠè¿°ã¹ãããšãã§ããŸãã å¿ èŠã§ãªãå Žåã¯ãçŽæ¥çãªäŸåé¢ä¿ã¯ãããŸããããéæ¥çãªäŸåé¢ä¿ã¯å¯èœã§ãã ãããã远跡ãå¿ èŠã§ãããçŽæ¥çãªäŸåé¢ä¿ã ãã§ååã§ãã
ããã¯éåžžã«ç°¡åã«å®çŸãããŸãïŒã°ããŒãã«å€æ°ã®ã©ããã§1ã€ã®ååã®èšç®ãéå§ããç¬éã«ãããã¯çŸåšã®ååã§ããããšãèšæ¶ãããä»ã®ååã®å€ãåãåã£ãç¬éã«ãå®éã«ãã®å€ãè¿ãããšã«å ããŠããããã¯äºãã«ãªã³ã¯ãããŠããŸãã ã€ãŸããå®éã®å€ã®ã¹ãããã«å ããŠãåã¢ãã ã«ã¯ãå é ã®ã¢ãã ïŒãã¹ã¿ãŒïŒãšã¹ã¬ãŒãïŒã¹ã¬ãŒãïŒã®2ã€ã®ã»ãããå¿ èŠã§ãã
ãªã³ã¯ã䜿çšãããšããã¹ãŠãããè€éã«ãªããŸããéå§æã«ã¯ãå é ã®ååã®ã»ããã空ã®ååã«çœ®ãæããå¿ èŠããããèšç®ãå®äºããããçµæã®ã»ãããåã®ååãšæ¯èŒããŠãæ°ããã»ããã«å«ãŸããŠããªãååããªã³ã¯ããŸãã
åæ§ã«ãèªå远跡ã®äŸåé¢ä¿ã¯KnockOutJSããã³MeteorJSã§æ©èœããŸãã
ããããååã¯å€èšç®ããã€åå®è¡ããããã©ã®ããã«ããŠç¥ãã®ã§ããããïŒ ããã«ããã«ã€ããŠã
2.äžè²«ããå€ã®ã«ã¹ã±ãŒãæŽæ°
ããã¯ç°¡åã ãšæãããã§ããããïŒ å€ãå€æŽããçŽåŸã«ãäŸåååã調ã¹ãŠæŽæ°ãéå§ããŸãã ããã¯ãŸãã«KnockOutJSãè¡ãããšã§ãããããã倧éæŽæ°äžã«é床ãäœäžããçç±ã§ãã ããšãã°ã1ã€ã®ååïŒAïŒãä»ã®2ã€ã®ååïŒBãCïŒã«äŸåããŠããå Žåããããã®å€ãé£ç¶çã«å€æŽãããšãååAã®å€ã2åèšç®ãããŸãã ããã§ã2ã€ã§ã¯ãªã2000ã®ååã«äŸåããåèšç®ã«å°ãªããšã10ããªç§ããããšæ³åããŠãã ããã
KnockOutJSéçºè ã«ãšã£ãŠthrottl-iniãšdebounce-erasã¯ããã«ããã¯ã«çœ®ãããŠããŸãããMeteorJSéçºè ã¯ããäœç³»çãªæ¹æ³ã§ãã®åé¡ã«åãçµã¿ãŸããïŒå³æã®ä»£ããã«äŸåååãåèšç®ããé 延åŒã³åºããè¡ããŸããã äžèšã®å Žåãã¢ãã Aã¯ãã®å€ãæ£ç¢ºã«1ååã«ãŠã³ãããçŸåšã®ã€ãã³ããã³ãã©ãŒã®æåŸãã€ãŸãã¢ãã BãCãããã³ãã®ä»ã«è¡ã£ããã¹ãŠã®å€æŽã®åŸã«ãããè¡ããŸãã
ããããããã¯å®éã«ã¯åé¡ã«å¯Ÿããå®å šãªè§£æ±ºçã§ã¯ãããŸãã-ã¢ãããã¯äŸåæ§ã®æ·±ãã2ãè¶ ãããšåã³ãããã¢ããããŸãããããç°¡åãªäŸã§èª¬æããŸããååAã¯ååBãšCã«äŸåããCã¯Dã«äŸåããŸããååBãšDãé çªã«å€æŽãããšãååAãšCãé ããŠã«ãŠã³ããããååCã®å€ãå€åãããšãAã®å€ã®é 延èšç®ãåã³éå§ãããŸããããã¯éåžžãé床ã«ãšã£ãŠããã»ã©èŽåœçã§ã¯ãããŸããããéåžžã«é·ãæäœããããåã«ããããšãã§ããŸã æãäºæ³å€ã®å Žæã®çšéã«æ³šããŸãã
åé¡ãç解ãããšã解決çãæãä»ãã®ã¯ç°¡åã§ããååããªã³ã¯ãããšãã¯ããªãŒããŒã®æ倧深床ãã©ã¹1ãèšæ¶ããã ãã§ååã§ãããŸããæŽæ°ã®ããã«åã£ãŠãããååãå埩åŠçãããšãã«ãããæµ ãååãæŽæ°ããŸãã ãã®ãããªåçŽãªææ³ã«ãããååã®å€ãåèšç®ããããŸã§ã«ãååãçŽæ¥äŸåãããã¹ãŠã®ååãå®éã®å€ãæã€ããšãä¿èšŒã§ããŸãã
3.äŸå€åŠç
ãã®ç¶æ³ãæ³åããŠãã ãããååBãšCã¯Aã«äŸåããŸããååBã¯å€ã®èšç®ãéå§ããAã«å€ãããŸããããŸãããã®å€ã®èšç®ãéå§ããŸãããããã®ç¬éã«äŸå€ãçºçããŸãã-ã³ãŒãã®èª€ããŸãã¯ããŒã¿ã®äžè¶³-éèŠã§ã¯ãããŸããã äž»ãªããšã¯ãã¢ãã Aããã®äŸå€ãèšæ¶ããå¿ èŠãããããBããããèšæ¶ãŸãã¯åŠçã§ããããã«ããããããã«ãããŒããããããšã§ãã ãªãããããããªã«éèŠãªã®ã§ããïŒ Cãå€ã®èšç®ãéå§ããŠAã«å€ãããšããã®ããã«çºçããã€ãã³ãã¯Bã®å Žåãšåãã«ãªãã¯ãã§ããAã«ã¢ã¯ã»ã¹ãããšãã€ã³ã¿ãŒã»ããããã³åŠçã§ããäŸå€ããããã¢ããããããäœãå®è¡ããã«äŸå€ãå®è¡ããå¿ èŠããããŸãã¢ãã ãå®è£ ããèšç®ãããã¢ãã ã«ä¿åãããŠããã©ã€ãã©ãªã«ãã£ãããããŸãã ã¢ãã ãäŸå€ãèšæ¶ããŠããªãã£ãå Žåãã¢ãã ã«ã¢ã¯ã»ã¹ãããšåãã³ãŒããèµ·åãããå¿ ç¶çã«åãäŸå€ãçºçããŸãã ããã¯ããã»ããµãªãœãŒã¹ã®ç¡é§ã§ãããããéåžžã®å€ã®ããã«ãã£ãã·ã¥ããããšããå§ãããŸãã
ãã1ã€ã®ãããã«éèŠãªç¹ã¯ãã«ã¹ã±ãŒãååã®æŽæ°äžã«ããããã®å€ãå察æ¹åã«èšç®ãããããšã§ãã ããšãã°ãã¢ãã Aã¯Bã«äŸåããããã¯Cã«äŸåããäžè¬çã«ã¯Dã«äŸåããŸããåæåãããšãAã¯ãã®å€ã®èšç®ãéå§ããŠBã«å€ãããCã«é²ã¿ãDã«é²ã¿ãŸãããã ããç¶æ ã¯éã®é åºã§æŽæ°ãããŸãã次ã«Cã次ã«BãæåŸã«AïŒ
ãã®åŸã誰ããã¢ãã Dã®å€ãå€æŽããŸãã圌ã¯ãã¢ãã Cã«ãã®å€ããã¯ãé¢ä¿ãªãããšãéç¥ããŸãã 次ã«ãã¢ãã Cã¯ãã®å€ãèšç®ããåã®å€ãšçãããªãå Žåãã¢ãã Bã«éç¥ããŸããããã¯åæ§ã«Aã«éç¥ããŸãããããã®ç¬éã«äŸå€ããã£ããããããã®çµæãäŸåååã«éç¥ããªãå Žåãç¶æ³ãååŸããŸããã¢ããªã±ãŒã·ã§ã³ãççŸããç¶æ ã«ãããšãïŒã¢ããªã±ãŒã·ã§ã³ã®ååã¯æ°ããããŒã¿ãå«ã¿ãååã¯å€ãããããã¯æ°ãããã®ã§ããããšã確å®ã§ããã3çªç®ã®ååã¯äžè¬çã«èœã¡ãŠããŒã¿ãå€æŽãããã®ãåŸ ã€ããšãã§ããŸããã
4.埪ç°äŸå
埪ç°äŸåã®ååšã¯ãããã°ã©ã ã®è«çãšã©ãŒã瀺ããŠããŸãã ãã ããä¿çäžã®èšç®ã®ç¡éã«ãŒãã§ããã°ã©ã ãããªãŒãºãŸãã¯ã¹ãã³ããããšã¯ãããŸããã 代ããã«ãã¢ãã ã¯ããã®å€ãèšç®ããŠäŸå€ãã¹ããŒããããã«ãã®å€ãå¿ èŠã§ããããšãæ€åºããå¿ èŠããããŸãã
ããã¯ç°¡åã«æ€åºãããŸãïŒèšç®ãéå§ããããšãã¢ãã ã¯èšç®ãããŠããããšãèšæ¶ãã誰ãããã®å€ã«æ»ããšãèšç®ç¶æ ã«ãããã©ããããã§ãã¯ããããã§ããã°äŸå€ãã¹ããŒããŸãã
5.éåæ
éåæã³ãŒãã¯ãããžãã¯ãã¹ãã²ããã£ã«å€ãããããåžžã«åé¡ã«ãªããŸããã¹ãã²ããã£ã®è€éãã远跡ããã®ã¯é£ããããã¹ãç¯ããããããã§ãã JavaScriptã§éçºãããšãã¯ãåçŽã§æ確ãªåæã³ãŒããšéåæåŒã³åºãã®éã§çµ¶ãããã©ã³ã¹ãåãå¿ èŠããããŸãã éåæã®äž»ãªåé¡ã¯ãã€ã³ã¿ãŒãã§ã€ã¹ãä»ããŠã¢ãããšããŠãªãŒã¯ããããšã§ããã¢ãžã¥ãŒã«Aã®åæå®è£ ãèšè¿°ããããã䜿çšããŠã¢ãžã¥ãŒã«Aãã¢ãžã¥ãŒã«Bããéåæã«éãã«å€æŽããããšã¯ã§ããŸããã ãã®ãããªå€æŽãè¡ãã«ã¯ãããã«äŸåããã¢ãžã¥ãŒã«BãCãããã³Dã®ããžãã¯ãå€æŽããå¿ èŠããããŸãã éåææ§ã¯ããã¹ãŠã®æœè±¡åãçªç Žããå éšã®å®çŸãæŒãé²ãããŠã€ã«ã¹ã®ãããªãã®ã§ãã
ããããååã¯ãã®åé¡ãç°¡åãã€ç°¡åã«è§£æ±ºããŸãããååã«ã€ããŠã¯ãŸã£ããèããŠããŸããã§ããããã¹ãŠãåå¿æ§ã§ãã ããã¢ãã ãå¥ã®ã¢ãã ã«å€ãããšãããçš®ã®çããããã«åŸããããã®éã«éåæã¿ã¹ã¯ãéå§ãããŸãããã®åŸãå€ãæŽæ°ãããåä¿¡ããããŒã¿ã«åŸã£ãŠã¢ããªã±ãŒã·ã§ã³å šäœãæŽæ°ãããŸãã å³æå¿çã«ã¯ãããã€ãã®ã¿ã€ãããããŸãã
aïŒããã©ã«ãå€ãè¿ããŸãã é§åãããååã®å Žåãã1ã€ã®å€ããããçªç¶å€åããŸãããããã«èŠããŸããã衚瀺ãããå®éã®ããŒã¿ãç解ããããšã¯ã§ããŸããã ãŸãããããç¥ãå¿ èŠãããããšããããããŸããããšãã°ãããŒã¿ãã©ãã«ãæ¶ãããããŒããããããšããŠãããšããã¡ãã»ãŒãžããŠãŒã¶ãŒã«è¡šç€ºããããã§ãã
bïŒããŒã«ã«ã«ãã£ãã·ã¥ãããããŒãžã§ã³ãè¿ããŸãã ãã®ãªãã·ã§ã³ã¯ãããŒã¿ã®å€æŽãæ¯èŒçãŸããªå Žåã«é©ããŠããŸãã ããšãã°ããã®èšäºã®åé ã®ãŠãŒã¶ãŒåã¯ãã¢ããªã±ãŒã·ã§ã³ã®èµ·åã®éã«ååãå€æŽããŠã倧äžå€«ã§ãããããã£ãŠã以åã®ååããã°ããã®éçèããŸãããã»ãšãã©ããã«ã¢ããªã±ãŒã·ã§ã³ã®æäœãéå§ã§ããŸãã ãã¡ããããã®ã¢ãããŒãã¯éèŠãªããŒã¿ã«ã¯é©ããŠããŸãããç¹ã«ãæ¥ç¶ã«åé¡ãããå Žåã¯ãæŽæ°ã«éåžžã«æéããããå¯èœæ§ããããŸãã
cïŒæ£çŽãªãšãããããŒã¿ããªããããŒã¿ããªãããšãæå³ããç¹å¥ãªå€ãè¿ããŸãã javascriptã®å Žåãããã¯æªå®çŸ©ã«ãªããŸãã ãããããã®å ŽåãäŸåã³ãŒãã®ãã¹ãŠã®å Žæã§ãã®å€ã®æ£ããåŠçãå¿ èŠã§ã-ããã¯ãééããç¯ããããã»ã©ååã«å€§éã®åãã¿ã€ãã®ã³ãŒãã§ããããããã®ãã¹ãéžæããããšã§ãNull Pointer Exceptionã«åããŠãã ããã
dïŒéåæã¿ã¹ã¯ãéå§ããåŸãç¹å¥ãªäŸå€ãã¹ããŒããŸããããã¯ãäžèšã®ããã«ããã¹ãŠã®äŸåã¢ãã ãåŠçå¯èœãªã¢ãã ã«ã«ã¹ã±ãŒãããŸãã ããšãã°ããŠãŒã¶ãŒã®ãªã¹ãã®è¡šç€ºãæ åœããã¢ãã ã¯ãäŸå€ããã£ããããéãã«èœã¡ãã®ã§ã¯ãªãããèªã¿èŸŒã¿äžããŸãã¯ãèªã¿èŸŒã¿ãšã©ãŒããšããã¡ãã»ãŒãžããŠãŒã¶ãŒã«è¡šç€ºããŸãã ã€ãŸããäœããã®ãªã¢ãŒãã¢ãã ããå§ããŠãäŸå€çãªç¶æ³ãéåžžã«èŠåçã«ãªããŸãã ãã®æ¹æ³ã®å©ç¹ã¯ãããŒã¿ã®äžè¶³ãæ¯èŒçå°æ°ã®ã³ãŒãå Žæã§ã®ã¿åŠçã§ãããããã®å ŽæãŸã§ã¯åŠçã§ããªãããšã§ãã ããããããã§éèŠãªã®ã¯ãããã€ãã®ã¢ãã ã«ãã£ãŠã¯ãäŸå€ãæåã«ã¹ããŒãããåŸã«èšç®ãåæ¢ããæ®ãã®ãŠãŒã¶ãŒã¯ããŒã¿ãå¿ èŠã§ããããšãç¥ããªãããšã§ãã 幞ããªããšã«ããããã®ç¬éã¯ãµãŒããŒãžã®éå°ãªãªã¯ãšã¹ãã«ãã£ãŠç°¡åã«æ€åºãããé©åãªå Žæã«try-catchãèšå®ããããšã§æ¥ãããããã«ä¿®æ£ãããŸããã
6.ç¹æš©ã³ãŒããšã®çµ±å
FRPãã©ããªã«çŸãããŠããç¹å¹è¬ã§ã¯ãªãããã¹ãŠã®åé¡ã解決ã§ããããã§ã¯ãããŸãããããã«ãåéã«ãªãããã«å¿ èŠãªå€ãã®åœä»€åã©ã€ãã©ãªãšãã€ãã£ãAPIããããŸãããããã£ãŠããŸã第äžã«ãã¢ãã ã®å€ãå€æŽãããšããäºå®ã«åºã¥ããŠä»»æã®ã³ãŒããå®è¡ããããšãå¯èœã§ããã¹ãã§ããããã«ãäžã§èª¬æããããã«ãçµã¿èŸŒã¿ã®é¢æ°ãä»ããã«ãå€ãçŽæ¥å€æŽã§ããå¿ èŠããããŸãããã ãããããã®æ©èœã®äœ¿çšã¯æå°éã«æããããšããå§ãããŸãããããã®æ©èœã䜿çšããã«ã¯ã泚æãšå®è£ ã®ç²ŸåºŠãé«ããå¿ èŠãããããã§ãã
䜿çšæŠç¥ã«å¿ããŠãååã3ã€ã®äž»èŠãªã¿ã€ãã«åå²ããããšãæ¡ä»¶çã«å¯èœã§ã
ãaïŒç¶æ ã®ãœãŒã¹ã¯ããã®å€ãèšç®ããæ¹æ³ãç¥ããªãååã§ãã誰ãããããå ·äœçã«é 眮ããå Žåã«ã®ã¿ãå€æŽããŸãã
bïŒäžé-é 延ç¶æ ã®ååãã¢ãã¬ã¹ãæå®ããããšãä»ã®ååã«åºã¥ããŠç¶æ ãèšç®ãããŸãããããã圌ãã«ä¿¡è ãããªãå Žåã圌ãã¯æå°è ããéäŒããŸããåæã«ãåã³å¿ èŠã«ãªã£ãå Žåã«åããŠã¡ã¢ãªã«æ®ããŠããããšãããªãœãŒã¹ãæ¶è²»ããªãããã«åé€ããããšãã§ããŸãã
cïŒç¶æ ç±æ¥-å€éšã®ç¶æ ã®å€åãåœä»€çã«åæ ããååã
7.ã¡ã¢ãªæ¶è²»
ããã§ã¯ãã¹ãŠãããã»ã©ãã©è²ã§ã¯ãããŸãã-å€ã1ãããã«åãŸãå Žåã§ããåã¢ãã ã¯æ°åãã€ãã®è¿œå æ å ±ãããèªäœã«æ ŒçŽããŸãã
ããã¯å žåçãªã¢ãã ãä¿åãããã®ã§ãïŒ
aïŒå®éã®å€
bïŒé€å€ã®ãªããžã§ã¯ãïŒå€ãšçµã¿åãããããšãã§ããŸããããã¹ãŠã®èšèªã§
ã¯ãããŸããïŒcïŒçŸåšã®ç¶æ ïŒé¢ä¿ãªããæŽæ°ãèšç»ãããŠãããèšç®ãé²è¡äžãé¢é£ããããšã©ãŒ...
dïŒå€ãã®å è¡ã¢ãã
eïŒé§åã¢ãã ã®ã»ãã
eïŒæ倧深ã
eïŒé§åã¢ãã ã®æ°
gïŒèå¥åïŒãã€ã³ã¿ã§èå¥ã§ããªãèšèªã®å ŽåïŒ
hïŒæãŸããåäœãå®è£ ããé¢æ°ã®æ
äŸåé¢ä¿ã°ã©ãã®ç²ŸåºŠã«ã¯ããªãã®è²»çšãããããŸããã¡ã¢ãªãç¯çŽããããã®ããã€ãã®æŠç¥ããããŸãïŒ
aïŒ1ã€ã®ã¢ãã ã«è€æ°ã®å€ãä¿åããããšã§ç²ŸåºŠãäžããŸãããã®çµæãè¿é£ã®ããŒã¿ãå€æŽããããšãã«ããã€ãã®èª€ã£ãéç¥ããããŸãããããã調ã¹ãã«ã¯ãå€ã®èšç®ãéå§ããå¿ èŠããããŸããããã¯ãAngularJSããã®$ãã€ãžã§ã¹ãã®é¡äŒŒç©ãçæããŸããã1ã€ã®ã¢ãã ã®ãã¬ãŒã ã¯ãŒã¯å ã§ã®ã¿ã§ãããåã«ãã§ããªãã£ããã ãã§ãªããã¢ãã ã§äœããå€æŽãããå Žåã®ã¿ã§ãã
bïŒäžéååã®æ°ãæžãããŸãããã¹ãŠã®äžéå€ããã£ãã·ã¥ã«é©ããŠããããã§ã¯ãããŸããããã®ãããå€ãã®å Žåãéåžžã®é¢æ°ãååã«éãå®è¡ãããå é ã®ã¢ãã ã®å€æŽãããŸãé »ç¹ã«çºçããªãå Žåã¯ãéåžžã®é¢æ°ã䜿çšã§ããŸãã
cïŒãœãŒã¹ååã®æ°ãæžãããŸããè€æ°ã®ãœãŒã¹ã®ä»£ããã«ããã©ã°ã©ãïŒaïŒã®ããã«1ã€æã€ããšãã§ããŸãããçŽæ¥ã¢ã¯ã»ã¹ããã®ã§ã¯ãªãããœãŒã¹ããããŒã¿ãåãåããå¿ èŠãªéšåã®ã¿ããã§ãã¯ããäžéã¢ãã ãä»ããŠã¢ã¯ã»ã¹ããŸãããã®ããã«ããŠãç§ãã¡ã¯ãã£ãšæªãããšãããŠããããã«æããŸã-äŸãã°ã10ã®ãœãŒã¹ã1ã€ã®ãœãŒã¹+ 10ã®äžéã«å€æŽããŠããŸãããã ãããœãŒã¹ã«ããããŒã¿ã倱ãããšãªããããŒã¿ãäžèŠãªå Žåã¯äžéã®ãã®ãèªå·±ç Žå£ã§ãããããå¿ èŠã«å¿ããŠãããã®ã¢ãã ããã°ãã埩å ã§ããŸãã
dïŒçµåã®æ°ãæå°éã«ããŸããããã€ãã®äž»èŠãªååã«åºã¥ããŠå€ãèšç®ããããã€ãã®äžéååãå°å ¥ãããšãçµåã®ç·æ°ãæžããããšãã§ããå ŽåããããŸãã
eïŒåäœãæå®ããé¢æ°ã¯ãã¢ãã èªäœã§ã¯ãªãããµãã¯ã©ã¹ã«é 眮ããå¿ èŠããããŸããåãããã«æ¯ãèãã¢ãã ãããããããå Žåã¯ããããã®ãµãã¯ã©ã¹ãäœæããŠãæ¯ãèããæå®ããç°ãªãããŒã¿ã®ã¿ãã€ã³ã¹ã¿ã³ã¹ã«ä¿åããã®ãæåã§ãã
ãšãããŒã°
èŠçŽãããšãååã®çé¢ã次ã®å³ã®åœ¢åŒã§äœç³»åããŸã
ãA-ååãå åŽã®åã¯åœŒã®ç¶æ ã§ãããããŠãå€éšã¯ãã®ã€ã³ã¿ãŒãã§ãŒã¹ã®å¢çã§ãã
Sã¯ã¢ããªã±ãŒã·ã§ã³ã®é§åéšåã§ãããã¢ãã ã ãã§ãªããçŸåšã®ã¢ãã ã«äœããã®åœ¢ã§äŸåãããã¹ãŠã®ãã®ãååšããå¯èœæ§ããããŸãã
Mã¯ãå€ãäŸåããäž»èŠéšåã§ãã
ç¢å°ã¯ããŒã¿ãããŒã瀺ããŸãããããã®ãã¡ãããšã³ãã¯ãçžäºäœçšã®ã€ãã·ãšãŒã¿ãŒã象城ããŠããŸãããŠãŒã¶ãŒå®çŸ©é¢æ°ã䜿çšããŠåäœãæå®ã§ããã€ã³ã¿ãŒãã§ã€ã¹ã¯ãèµ€ã§ããŒã¯ãããŠããŸãã
ãããŠãã€ã³ã¿ãŒãã§ãŒã¹ã«ã€ããŠã®è©³çŽ°ïŒ
get-value requestãå€ãé¢ä¿ãªãå Žåã¯ããã«ãèµ·åããŠæŽæ°ããŸãã
pullã¯ãååã®å€ãèšç®ãããŸãã«ãã®æ©èœã§ãã圌ã¯èªåã®å€ãæŽæ°ããããšã決å®ãããšããã®é¢æ°ãåŒã³åºããŸãããã®äžã§ãéåæãªã¯ãšã¹ããå®è£ ããããã·ã¥ã€ã³ã¿ãŒãã§ãŒã¹ãä»ããŠå€ãã¢ãã ã«å ¥ããããšãã§ããŸãã
push-ã¢ãã ã®æ°ããå€ãèšå®ããŸããããã®ãŸãŸã§ã¯ãªãä¿åãããŸãããæåã«ããŒãžã€ã³ã¿ãŒãã§ã€ã¹ã«æž¡ãããŸã
merge-æ°ããå€ãšçŸåšã®å€ãããŒãžããŸããæ£èŠåãããŒãã£ãã§ãã¯ãæ€èšŒããããŸãã
notify-å€æŽã«é¢ããã¹ã¬ãŒããžã®éç¥ã
fail-ãšã©ãŒã«é¢ããã¹ã¬ãŒãã®éç¥ã
set-ãã®ã€ã³ã¿ãŒãã§ã€ã¹ãä»ããŠãã¹ã¬ãŒãã¢ãã ã¯ãã¹ã¿ãŒã«æ°ããå€ãæäŸã§ããŸããããŒãžåŸã®æ°ããå€ãçŸåšã®å€ãšç°ãªãå ŽåãputãåŒã³åºãããŸãã
put-ããã©ã«ãã§ããã·ã¥ããŸããããã®ç®çã¯ããªãŒãã¢ãã ã«æ°ããç¶æ ãæäŸããããšã§ãã
ããã§ãã¹ãŠã§ãããã®èšäºã¯ãã§ã«ããªãé·ããã»ãšãã©ãçè«çã§ããããšãå€æããŸãããç¶ç·šã§ã¯ãjavascriptã©ã€ãã©ãªã$ jin.atomãã®äœ¿çšæ¹æ³ãããã«å¢ããŸããäžèšã«å ããŠãã©ã®ããã«æ©èœããããã©ã®æé©åã䜿çšãããããåŠã³ãŸãããããŠãã¡ãããå®çšçãªäŸããããŸããç¶ç¶ã
èŠè¶ããŠãèªåã§ååãå®çŸããããšããããšããå§ãããŸãã次ã«ããœãªã¥ãŒã·ã§ã³ãæ¯èŒããããšã¯èå³æ·±ãã§ãããã