GUIãæã¤ã¢ããªã±ã¼ã·ã§ã³ã®è¨è¨ã§ã¯ãã½ããã¦ã§ã¢ã¢ã¼ããã¯ãã£ãã¿ã¼ã³*1ã¨ãã¦MVCãã¿ã¼ã³ã使ç¨ããMVCãã¿ã¼ã³ãå®ç¾ããä¸ã§ãModelã®å¤æ´ãViewãControllerã¸éç¥ããä»çµã¿ã«ãã¶ã¤ã³ãã¿ã¼ã³*2ã¨ãã¦Observerãã¿ã¼ã³ã使ç¨ããã®ãå¤å ¸çå®çªã§ãã
ã¨ããããObserverãã¿ã¼ã³ã使ã£ãModelã«ã¯ãObservableã®ãªã¹ãã管çããç¶æ å¤æ´ã®éã«ãªã¹ãã«ç»é²ãããObserbableå ¨ã¦ã«éç¥ããä»çµã¿ãå®è£ ããå¿ è¦ããããçµæ§ãªä½æ¥ã¨ãªãã¾ã*3ã
ãã®Modelããã®éç¥ãObserverãã¿ã¼ã³ã§å®ç¾ãã代ããã«ãã¤ãã³ããã¹ã使ã£ã¦å®ç¾ããã¨ãModelã®å®è£ ãç°¡æ½ã«ãããã¨ãã§ãã¾ããJava SEã§ã¯ãã¾ãäºä¾ãè¦ããã¾ããããAndroidã§ã¯å²ã¨ã¡ã¸ã£ã¼ã«ä½¿ããã¦ããããã§ãã
å æ¥ãAndroidã§ã¤ãã³ããã¹ã®ã©ã¤ãã©ãªã調ã¹ã¦ããã¨ãã«ãéåæã³ã¼ã«ããã¯å°çããè±å´ããæ¹æ³ã¨ãã¦ãRxAndroidï¼RxJavaï¼ã使ãã¨ããè¨äºãè¦ããã¾ãããé ã®çé ã«çããç¨åº¦ã«ãã¦ãã¾ããããä»åº¦ã¯Java SEã§ä½¿ãã¤ãã³ããã¹ã©ã¤ãã©ãªã調ã¹ã¦ããã¨ãã«ãstackoverflowã®æ¬¡ã®è¨äºãç®ã«ã¨ã¾ãã¾ããã
å 容ãç®æ¡æ¸ãã§ç°¡åã«ã¾ã¨ããã¨ã
- Scalaã¨JavaFXã§ã¢ããªã±ã¼ã·ã§ã³ãä½ãéã«ãObserverãã¿ã¼ã³ãããã¤ãã³ããã¹ã好ãã§ä½¿ã£ã¦ãã
- æè¿ãªã¢ã¯ãã£ãããã°ã©ãã³ã°ãåå¼·ããã¨ãããObserverãã¿ã¼ã³ãç°¡æ½ã«ããï¼callback hellã解æ¶ï¼ã¨ãã
- ããã§ãç¹ã«ã·ã³ã°ã«ã¹ã¬ããç°å¢ã§ã¯ã¤ãã³ããã¹ã§ã¯ãªãRxJavaã使ã£ãæ¹ãå®è£ ãç°¡æ½ã«ãªãã®ã§ã¯ï¼ã¨æ°ã«ãªã£ã
- RxJavaãã¤ãã³ããã¹ããããã¨ããã¯ä½ã§ããï¼
ã¨ããæ稿ããããããã«ããããåçãå¯ãããã¦ãã¾ãã
- scalafxï¼javafxï¼ã«ã¯ç¬èªã®Observableãããããscalafxã®bindã¯ç°¡åã ã
- ReactFX調ã¹ã¦ã¿ãã
- RxãReactFXã®ã¤ãã³ãã¹ããªã¼ã ã¯ã¤ãã³ããã¹ããã³ã¼ããæçã«ããã1)ã¤ãã³ããã¹ã¯ã°ãã¼ãã«ãªãã¸ã§ã¯ãã2)ã¤ãã³ãã¹ããªã¼ã ã«ã¯ã¤ãã³ãã®filter/transform/combineã¨ãã£ãæ¼ç®ãç¨æããã¦ãããç¶æ ãé è½ããç¶æ ãå¯ä½ç¨ãæ¸ãããã¨ãã§ãã
- ã¤ãã³ããã¹ã§ã¯ã³ã³ãã¼ãã³ãAã¨ã³ã³ãã¼ãã³ãBãéæ¥çã«çµåããã®ã§ãæ¥ç¶ãä¸æçããªã¢ã¯ãã£ããªããä¸ç®æã«a.events().subscribe(b::handle)ã¨æ¸ãããã¤ãã³ããã¹ã§ã¯ããå ´æã§eventBus.register(b); å¥ãªå ´æã§eventBus.post(evt); ã¨æ¸ãã
ã¾ããRxJavaã使ã£ã¦Event Busãå®è£
ããã¨ããããã°ãããã¾ããã
http://nerds.weddingpartyapp.com/tech/2014/12/24/implementing-an-event-bus-with-rxjava-rxbus/
ã¾ãããããªè¨äºãè¦ããã¾ããã
Reactive programming vs Event bus : androiddev
*1:MVCãã¿ã¼ã³ã¯ãæ¸ç±ãã½ããã¦ã§ã¢ã¢ã¼ããã¯ãã£âã½ããã¦ã§ã¢éçºã®ããã®ãã¿ã¼ã³ä½ç³»ãï¼é称POSAæ¬ï¼ã§ã¢ã¼ããã¯ãã£ãã¿ã¼ã³ã«åé¡ããã
*2:æ¸ç±ããªãã¸ã§ã¯ãæåã«ãããåå©ç¨ã®ããã®ãã¶ã¤ã³ãã¿ã¼ã³ãï¼é称GoFæ¬ï¼
*3:ã¹ã¬ããã»ã¼ãã«ä½æããã«ã¯ãObservableãªã¹ããã³ãã¼ãã¦ããéç¥ããã¨ããCopyOnWriteArrayListã使ãã¨ããObservableã®ã¤ã³ã¿ãã§ã¼ã¹ãç¨æããã¨ãã