This document provides an introduction to reactive programming in Shiny. It discusses key concepts of reactivity including sources, conductors, and endpoints. Reactivity is achieved by re-running expressions when their inputs change. Sources notify dependents of changes using invalidation events, triggering re-runs. Conductors cache intermediate results to improve performance. The isolate function prevents reactivity by using the latest values without re-running on changes. observeEvent and eventReactive allow controlling reactivity by tying it to input triggers rather than automatic re-running on changes.
You can get clear knowledge about the functional dependencies in "Normalization". And also the rules, types of FDs and finally the closure and its applications
You can get clear knowledge about the functional dependencies in "Normalization". And also the rules, types of FDs and finally the closure and its applications
A grammar is said to be regular, if the production is in the form -
A → αB,
A -> a,
A → ε,
for A, B ∈ N, a ∈ Σ, and ε the empty string
A regular grammar is a 4 tuple -
G = (V, Σ, P, S)
V - It is non-empty, finite set of non-terminal symbols,
Σ - finite set of terminal symbols, (Σ ∈ V),
P - a finite set of productions or rules,
S - start symbol, S ∈ (V - Σ)
Query processing and Query OptimizationNiraj Gandha
This presentation is made with many efforts and I believe that it will be proven as good presentation to clear the basic of query processing and optimization under the DBMS subject. The topics covered in this presentation are the basic fundamentals of the topic as suggested.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...Raj vardhan
The Relational Data Model and Relational Database Constraints
Ch5 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Example of STUDENT Relation(figure 5.1)
A grammar is said to be regular, if the production is in the form -
A → αB,
A -> a,
A → ε,
for A, B ∈ N, a ∈ Σ, and ε the empty string
A regular grammar is a 4 tuple -
G = (V, Σ, P, S)
V - It is non-empty, finite set of non-terminal symbols,
Σ - finite set of terminal symbols, (Σ ∈ V),
P - a finite set of productions or rules,
S - start symbol, S ∈ (V - Σ)
Query processing and Query OptimizationNiraj Gandha
This presentation is made with many efforts and I believe that it will be proven as good presentation to clear the basic of query processing and optimization under the DBMS subject. The topics covered in this presentation are the basic fundamentals of the topic as suggested.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...Raj vardhan
The Relational Data Model and Relational Database Constraints
Ch5 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Example of STUDENT Relation(figure 5.1)
Reactive Qt - Ivan Čukić (Qt World Summit 2015)Ivan Čukić
Reactive programming is an emerging discipline which achieves concurrency using events-based programming. Today, It is mostly used for writing very scalable web services that can achieve high concurrency levels even on a single thread.
The concept is simple - make a system that is fully event-based, and look at events not as isolated instances, but as streams. When we have streams, we can manipulate them as if they were simple ranges. We can filter them, modify them, combine multiple streams into one etc.
Reactive programming is not only applicable to the web services, it can be used in any event-based environment. In our case, in normal Qt applications, to enrich the power of signals and slots.
[...]
Similar to Introduction to reactive programming with R and Shiny (6)
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Looking for a reliable mobile app development company in Noida? Look no further than Drona Infotech. We specialize in creating customized apps for your business needs.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Łukasz Chruściel
No one wants their application to drag like a car stuck in the slow lane! Yet it’s all too common to encounter bumpy, pothole-filled solutions that slow the speed of any application. Symfony apps are not an exception.
In this talk, I will take you for a spin around the performance racetrack. We’ll explore common pitfalls - those hidden potholes on your application that can cause unexpected slowdowns. Learn how to spot these performance bumps early, and more importantly, how to navigate around them to keep your application running at top speed.
We will focus in particular on tuning your engine at the application level, making the right adjustments to ensure that your system responds like a well-oiled, high-performance race car.
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
OpenMetadata Community Meeting - 5th June 2024OpenMetadata
The OpenMetadata Community Meeting was held on June 5th, 2024. In this meeting, we discussed about the data quality capabilities that are integrated with the Incident Manager, providing a complete solution to handle your data observability needs. Watch the end-to-end demo of the data quality features.
* How to run your own data quality framework
* What is the performance impact of running data quality frameworks
* How to run the test cases in your own ETL pipelines
* How the Incident Manager is integrated
* Get notified with alerts when test cases fail
Watch the meeting recording here - https://www.youtube.com/watch?v=UbNOje0kf6E
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Do you want Software for your Business? Visit Deuglo
Deuglo has top Software Developers in India. They are experts in software development and help design and create custom Software solutions.
Deuglo follows seven steps methods for delivering their services to their customers. They called it the Software development life cycle process (SDLC).
Requirement — Collecting the Requirements is the first Phase in the SSLC process.
Feasibility Study — after completing the requirement process they move to the design phase.
Design — in this phase, they start designing the software.
Coding — when designing is completed, the developers start coding for the software.
Testing — in this phase when the coding of the software is done the testing team will start testing.
Installation — after completion of testing, the application opens to the live server and launches!
Maintenance — after completing the software development, customers start using the software.
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
In the ever-evolving landscape of technology, enterprise software development is undergoing a significant transformation. Traditional coding methods are being challenged by innovative no-code solutions, which promise to streamline and democratize the software development process.
This shift is particularly impactful for enterprises, which require robust, scalable, and efficient software to manage their operations. In this article, we will explore the various facets of enterprise software development with no-code solutions, examining their benefits, challenges, and the future potential they hold.
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Introduction to reactive programming with R and Shiny
1. Confidential – do not duplicate or redistribute without permission from xtream srl
An introduction to reactive programming in Shiny
Milan, 13th September 2018
2. 2 Contents
➢ What is reactive programming?
➢ Sources, conductors and endpoints
➢ Preventing reactivity: isolate
➢ observeEvent and eventReactive
3. 1. Road to reactivity
What is reactive programming and why you should care about it
4. 4
A one-way trip (1/3)
> x <- 1
> print(x)
[1] 1
> x <- 2
When the last statement is executed,
the value of x becomes 2, but the
printed value does not change
(obviously!)
5. 5
A one-way trip (2/3)
> x <- 1
> y <- x + 1
> print(y)
[1] 2
> x <- 2
> print(y)
[1] 2
When the value of x changes, the value
of y does not, because the two
variables are not linked together
(obviously!)
6. 6
A one-way trip (3/3)
print(x)
x x
x + 1
In the non-reactive realm, expressions
evaluate their input only when they
need, if an input changes after the
expression has been evaluated, the
result is not affected.
There are no push notifications!
7. 7
The magic reactive world
# app.R
library(shiny)
ui <- fluidPage(
sidebarPanel(
sliderInput("n", label = "input", min = 0, max = 100, value = 50)
),
mainPanel(h1(textOutput("out")))
)
server <- function(input, output) {
output$out <- renderText(input$n)
}
shinyApp(ui = ui, server = server)
8. 8 Up to here…
➢ Non-reactive expressions are lazy: they evaluate their input only when they are run
➢ This means that they cannot react to input changes
➢ Reactive expressions seems to go the other way round, reacting to input changes
➢ This is not how it actually works
9. 9
➢ Reactivity is a feature added on top
of a language, it must follow the rule
of the language
➢ The only way to update the result of
an expression is re-running it
Everything is reactive
If you kindly ask
50Reactive
source
50Reactive
endpoint
10. 10
➢ Reactivity is a feature added on top
of a language, it must follow the rule
of the language
➢ The only way to update the result of
an expression is re-running it
Everything is reactive
If you kindly ask
60
50
Reactive
source
Reactive
endpoint
11. 11
➢ Reactivity is a feature added on top
of a language, it must follow the rule
of the language
➢ The only way to update the result of
an expression is re-running it
Everything is reactive
If you kindly ask
60
50 RE-RUN!
Reactive
source
Reactive
endpoint
12. 12
➢ Reactivity is a feature added on top
of a language, it must follow the rule
of the language
➢ The only way to update the result of
an expression is re-running it
➢ This is what reactivity does. With
this approach, we don’t even need
to know what to re-run. Maybe.
Everything is reactive
If you kindly ask
60
60
Reactive
source
Reactive
endpoint
13. 13
➢ We cannot re-run everything so fast
that the user does not even perceive
it
➢ We have to be smart
Lazyness
The right way
10Reactive
source
30
Reactive
endpoint
20
+
Reactive
conductor
14. 14
➢ We cannot re-run everything so fast
that the user does not even perceive
it
➢ We have to be smart
Lazyness
The right way
10Reactive
source
30
Reactive
endpoint
40
+
Reactive
conductor
15. 15
➢ We cannot re-run everything so fast
that the user does not even perceive
it
➢ We have to be smart
Lazyness
The right way
10Reactive
source
30
Reactive
endpoint
40
+
Reactive
conductor
16. 16
➢ We cannot re-run everything so fast
that the user does not even perceive
it
➢ We have to be smart
Lazyness
The right way
10Reactive
source
30
Reactive
endpoint
40
+
Reactive
conductor
RE-RUN!
17. 17
➢ We cannot re-run everything so fast
that the user does not even perceive
it
➢ We have to be smart
Lazyness
The right way
10Reactive
source
30
Reactive
endpoint
40
+
Reactive
conductor
RE-RUN!
RE-RUN!
18. 18
➢ We cannot re-run everything so fast
that the user does not even perceive
it
➢ We have to be smart
➢ If we implement a proper cache-
invalidation system, we can only re-
run what needs to be. But how?
Lazyness
The right way
10Reactive
source
50
Reactive
endpoint
40
+
Reactive
conductor
19. 19
➢ Reactive sources and conductor have a
dirty flag, meaning the cached results are
no longer valid
➢ Reactive sources and conductors know
which objects depend on them, and can
make them dirty, though an invalidation
event
➢ When an endpoint gets dirty, it is re-run.
➢ DANGER. If more endpoints get dirty at
the same time, there is no way of knowing
or imposing the execution order
Homing Pigeons
10Reactive
source
20
Reactive
endpoint
10
+
Reactive
conductor
20. 20
➢ Reactive sources and conductor have a
dirty flag, meaning the cached results are
no longer valid
➢ Reactive sources and conductors know
which objects depend on them, and can
make them dirty, though an invalidation
event
➢ When an endpoint gets dirty, it is re-run.
➢ DANGER. If more endpoints get dirty at
the same time, there is no way of knowing
or imposing the execution order
Homing Pigeons
10Reactive
source
20
Reactive
endpoint
40
+
Reactive
conductor
DIRTY
21. 21
➢ Reactive sources and conductor have a
dirty flag, meaning the cached results are
no longer valid
➢ Reactive sources and conductors know
which objects depend on them, and can
make them dirty, though an invalidation
event
➢ When an endpoint gets dirty, it is re-run.
➢ DANGER. If more endpoints get dirty at
the same time, there is no way of knowing
or imposing the execution order
Homing Pigeons
10Reactive
source
20
Reactive
endpoint
40
+
Reactive
conductor
DIRTY
INVALIDATE!
22. 22
➢ Reactive sources and conductor have a
dirty flag, meaning the cached results are
no longer valid
➢ Reactive sources and conductors know
which objects depend on them, and can
make them dirty, though an invalidation
event
➢ When an endpoint gets dirty, it is re-run.
➢ DANGER. If more endpoints get dirty at
the same time, there is no way of knowing
or imposing the execution order
Homing Pigeons
10Reactive
source
20
Reactive
endpoint
40
+
Reactive
conductor
DIRTY
DIRTY
23. 23
➢ Reactive sources and conductor have a
dirty flag, meaning the cached results are
no longer valid
➢ Reactive sources and conductors know
which objects depend on them, and can
make them dirty, though an invalidation
event
➢ When an endpoint gets dirty, it is re-run.
➢ DANGER. If more endpoints get dirty at
the same time, there is no way of knowing
or imposing the execution order
Homing Pigeons
10Reactive
source
20
Reactive
endpoint
40
+
Reactive
conductor
DIRTY
INVALIDATE!
24. 24
➢ Reactive sources and conductor have a
dirty flag, meaning the cached results are
no longer valid
➢ Reactive sources and conductors know
which objects depend on them, and can
make them dirty, though an invalidation
event
➢ When an endpoint gets dirty, it is re-run.
➢ DANGER. If more endpoints get dirty at
the same time, there is no way of knowing
or imposing the execution order
Homing Pigeons
10Reactive
source
20
Reactive
endpoint
40
+
Reactive
conductor
DIRTY
RE-RUN!
25. 25
➢ Reactive sources and conductor have a
dirty flag, meaning the cached results are
no longer valid
➢ Reactive sources and conductors know
which objects depend on them, and can
make them dirty, though an invalidation
event
➢ When an endpoint gets dirty, it is re-run.
➢ DANGER. If more endpoints get dirty at
the same time, there is no way of knowing
or imposing the execution order
Homing Pigeons
10Reactive
source
20
Reactive
endpoint
40
+
Reactive
conductor
DIRTY
RE-RUN!
26. 26
➢ Reactive sources and conductor have a
dirty flag, meaning the cached results are
no longer valid
➢ Reactive sources and conductors know
which objects depend on them, and can
make them dirty, though an invalidation
event
➢ When an endpoint gets dirty, it is re-run.
➢ DANGER. If more endpoints get dirty at
the same time, there is no way of knowing
or imposing the execution order
Homing Pigeons
10Reactive
source
50
Reactive
endpoint
40
+
Reactive
conductor
27. 27
➢ When a reactive expression parent
executes another one child, it leaves there
an homing pigeon, capable of reaching
the parent again
➢ When the child gets dirty, it frees the
homing pigeon
➢ When the homing pigeon gets to the
parent, it makes it dirty.
➢ This is why you cannot use a reactive
expression outside a reactive context.
Nobody leaves the pigeon.
Homing Pigeons
Why this title?
28. 28 Up to here…
➢ Reactivity is nothing but a smart way of re-running expressions
➢ Results are cached, so that you don’t re-run something if you already have its result
➢ Reactivity uses messages: reactive expressions know which ones need their result
and can ask them to re-run them if their result changes
➢ We don’t need to go deeper in the implementation details
30. 30
➢ Instances of class reactivevalues
➢ Created by reactiveValues or
reactiveVal
➢ The default object input is a
collection of reactive sources
➢ When they change, they invalidate all
the objects which depend on them
Reactive sources
Reactive
source
31. 31
➢ Created by render* or observe*
functions – e.g. renderText,
observeEvent, …
➢ The default object output is a
collection of reactive endpoints
➢ When invalidated, they re-run within a
negligible time.
➢ They do not return values, but they
perform actions – e.g. writing a log file,
updating the ui, …
Reactive endpoints
Reactive
endpoint
32. 32
➢ Special functions created by the
*reactive functions (e.g.
reactive, eventReactive, …)
➢ Functions: they must return some
value. The result of the last
expression is returned by default
➢ When invalidated, they invalidate all
the conductors and the endpoints
which depend on them
Reactive conductors
Reactive
conductor
36. 36
➢ A reactive endpoint depends on two
sources
➢ But you want the endpoint to be
recomputed only if one of them
changes
➢ Of course, you want that, when the
endpoint is re-run, it uses the most
updated value for both the sources
Preventing reactivity
10Reactive
source
30
Reactive
endpoint
20
isolate()
37. 37
➢ A reactive endpoint depends on two
sources
➢ But you want the endpoint to be
recomputed only if one of them
changes
➢ Of course, you want that, when the
endpoint is re-run, it uses the most
updated value for both the sources
Preventing reactivity
10Reactive
source
30
Reactive
endpoint
40
isolate()
38. 38
➢ A reactive endpoint depends on two
sources
➢ But you want the endpoint to be
recomputed only if one of them
changes
➢ Of course, you want that, when the
endpoint is re-run, it uses the most
updated value for both the sources
Preventing reactivity
20Reactive
source
30
Reactive
endpoint
40
isolate()
DIRTY
39. 39
➢ A reactive endpoint depends on two
sources
➢ But you want the endpoint to be
recomputed only if one of them
changes
➢ Of course, you want that, when the
endpoint is re-run, it uses the most
updated value for both the sources
Preventing reactivity
20Reactive
source
30
Reactive
endpoint
40
INVALIDATE!
DIRTY
isolate()
40. 40
➢ A reactive endpoint depends on two
sources
➢ But you want the endpoint to be
recomputed only if one of them
changes
➢ Of course, you want that, when the
endpoint is re-run, it uses the most
updated value for both the sources
Preventing reactivity
20Reactive
source
30
Reactive
endpoint
40
RE-RUN!
DIRTY
41. 41
➢ A reactive endpoint depends on two
sources
➢ But you want the endpoint to be
recomputed only if one of them
changes
➢ Of course, you want that, when the
endpoint is re-run, it uses the most
updated value for both the sources
Preventing reactivity
20Reactive
source
60
Reactive
endpoint
40
isolate()
42. 42
Assuming a couple of numeric inputs
n1 and n2 exists:
output$computed = renderText(
input$n1 + isolate(input$n2)
)
Preventing reactivity
The code
20Reactive
source
60
Reactive
endpoint
40
isolate()
44. 44 Why controlling reactivity?
➢ You have a massive application, which let the user analyse data and tune some
parameter of a super-cool machine learning model
➢ Users can train the model against data, but this is a long, long procedure
➢ You don’t want model training to be triggered each time a user changes a
parameter, even if the model naturally depends on them
➢ So, you want to add a button to trigger the training algorithm, but you want training
to use the most updated values of parameters
46. 46
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
numericInput("n", "Input:", value = 10),
actionButton('go', 'Go!')
),
mainPanel(
h1("Result"),
textOutput("computed")
)
)
)
server <- function(input, output) {
step2 = step1 = function(x){
Sys.sleep(1)
x+1
}
output$computed = renderText({
input$go
s1 = isolate(step1(input$n))
isolate(step2(s1))
})
}
shinyApp(ui = ui, server = server)
➢ An actionButton returns a
number which is incremented by 1
each time it is pressed
➢ We take a reactive dependency
from go and we isolate all the rest
➢ This is not handy, nor readable. Why
should we use a reactive context if
we isolate all the inputs but one?
Controlling reactivity
A first attempt
47. 47
server <- function(input, output) {
step2 = step1 = function(x){
Sys.sleep(1)
x+1
}
res = eventReactive(
input$go, {
s1 = step1(input$n)
step2(s1)
})
output$computed = renderText(
res()
)}
shinyApp(ui = ui, server = server)
Controlling reactivity
The right way
goReactive
source
computed
Reactive
endpoint
n
isolate()
res
48. 48
➢ eventReactive has two main
arguments:
➢ A reactive expression to take
dependency on
➢ An expression to run when the first
argument gets invalidated
➢ It is a reactive conductor: it returns a
value
➢ Under the hood, it translate almost
exactly in the first example
➢ But this is more straightforward and
readable!
Controlling reactivity
The right way
server <- function(input, output) {
step2 = step1 = function(x){
Sys.sleep(1)
x+1
}
res = eventReactive(
input$go, {
s1 = step1(input$n)
step2(s1)
})
output$computed = renderText(
res()
)}
shinyApp(ui = ui, server = server)
49. 49
server <- function(input, output) {
write_log_2 = write_log_1 =
function(x){
Sys.sleep(1)
print(x)
}
observeEvent(
input$go,
{
write_log_1(input$n)
write_log_2(input$n)
})
}
Controlling reactivity
The right way
goReactive
source
Reactive
endpoint
n
isolate()
50. 50
➢ observeEvent has two main
arguments:
➢ A reactive expression to take
dependency on
➢ An expression to run when the
first argument gets invalidated
➢ It is not a reactive conductor, but a
reactive endpoint. It does not return
any value.
Controlling reactivity
The right way
server <- function(input, output) {
write_log_2 = write_log_1 =
function(x){
Sys.sleep(1)
print(x)
}
observeEvent(
input$go,
{
write_log_1(input$n)
write_log_2(input$n)
})
}
51. 51
Use observeEvent whenever you want
to perform an action in response to an
event. Note that "recalculate a value"
does not generally count as performing
an action – see eventReactive for
that.
Use eventReactive to create a
calculated value that only updates in
response to an event.
This is just like a normal reactive
expression except it ignores all the
usual invalidations that come from its
reactive dependencies; it only
invalidates in response to the given
event.
observeEvent eventReactive
observeEvent vs
eventReactive
Source: https://shiny.rstudio.com/reference/shiny/1.0.0/observeEvent.html
52. 52 Resources
The best place to start learning Shiny is the documentation home page:
https://shiny.rstudio.com/tutorial/
Here you can find lots of pointers to articles, videos and tutorials.