Path: blob/main/doc/explanation/api/examples/stocks_callbacks.md
2014 views
Stock Explorer - Callback API
Before launching into the application code we will first declare some components of the app that will be shared, including the title of the app, a set of stock tickers, a function to return a dataframe given the stock ticker
and the rolling mean window_size
, and another function to return a plot given those same inputs:
This example demonstrates how APIs in Panel differ, to see the same app implemented using a different API visit:
Other APIs in Panel are all reactive in some way, triggering actions whenever manipulating a widget causes a parameter to change, without users writing code to trigger callbacks explicitly. On the other hand, the callback based API allows complete low-level control of precisely how the different components of the app are updated, but this can quickly become unmaintainable because the complexity increases dramatically as more callbacks are added. The approach works by defining callbacks using the .param.watch
API that either updates or replaces the already rendered components when a watched parameter changes: