This document discusses reactive programming with R and using Reactlog to better understand reactivity in Shiny apps. It provides an overview of reactive programming concepts like reactive sources, conductors, and endpoints. It also explains what Reactlog is and how it can be used to track the execution of reactive objects in a Shiny app over time, visualizing the life cycle and dependencies between different reactive elements. Installing and using Reactlog to debug reactivity is also covered. The document aims to help readers who are intermediate Shiny users gain a better understanding of reactive programming.
20. Z에서 출력되는 값은?
X <- 10
Y <- 20
Z <- X + Y
X <- 11
Y <- 22
Print(Z)
https://www.slideshare.net/jongwookkim/ndc14-rx-functional-reactive-programming
NonReactive Programming Reactive Programming
21. 데이터/이벤트 기반 프로그래밍
X <- 10
Y <- 20
Z <- X + Y
X <- 11
Y <- 22
Print(Z)
https://www.slideshare.net/jongwookkim/ndc14-rx-functional-reactive-programming
“순차적 Control Flow” “동시적 Data Flow”
24. Side Effect in Programming
X = 2
함수1 호출
X = 2
X = 2
함수2 호출
X = 4
1) 함수가 함수 자신의 범위(Scope) 밖에서 영향을 주는 경우
2) 함수는 결과를 반환하지 않을 수 있음
Side Effect
25. Side Effect in R
https://cdn.rawgit.com/jcheng5/user2016-tutorial-shiny/master/slides.html
26. Side Effect in Shiny R
https://cdn.rawgit.com/jcheng5/user2016-tutorial-shiny/master/slides.html
1) 함수가 함수 자신의 범위(Scope) 밖에서 영향을 주는 경우
2) 함수는 결과를 반환하지 않을 수 있음
27. Not Side Effect in R
https://cdn.rawgit.com/jcheng5/user2016-tutorial-shiny/master/slides.html
35. Implementation of Reactive Object
Reactive value : “input” 웹브라우저를 통한 ui 입력
Reactive Expression :
데이터 베이스 접근, 파일읽기, 오래걸리는 연산
Observer : “output” renderXX의 할당 연산자 오퍼랜드
36. Stop reactions with isolate()
https://shiny.rstudio.com/gallery/actionbutton-demo.html
55. What is reactlog?
• Reactive log를 전/후 시점으로 동작을 추적
• 정의된 Reactive Object 검색 가능
• Cytoscape.js로 구현
설치방법
실행방법
56. reActivity Being Recorded
• Reactivity
• Reactive 객체정의
• Invalidating reactive 객체의 시작/종료
• Isolating reactive 객체의 시작/종료
• Reactive 의존성 추가/삭제
• Value
• Value의 변화
• 연산의 시작과 끝
• Extra
• 사용자 체크 지점의 연산 시간
• Shiny Idle
57. Reactive Life Cycle in Reactlog
The reactive element has finished executing. For
reactive conductors (such as the result
of reactive()), a calculated value is available.
The reactive element has started executing. During
calculation, direct dependencies will be added.
This is the opposite of calculating, the reactive element is
resetting it’s value and removing all direct dependencies.
The reactive element has been reset and is waiting to
calculate.
A visual display of a frozen reactiveVal key. These elements
behave as if their execution is done with req(FALSE).