0
# Links System
1
2
Advanced reactive programming system for creating property links between Panel components and Bokeh models. Enables sophisticated reactive patterns and cross-component data synchronization without Python callback overhead.
3
4
## Capabilities
5
6
### Property Linking
7
8
Core classes for establishing reactive links between component properties.
9
10
```python { .api }
11
class Link:
12
"""
13
Base class for linking properties between components.
14
15
Parameters:
16
- source: Source component with properties to link from
17
- target: Target component with properties to link to
18
- properties: Dictionary mapping source properties to target properties
19
- bidirectional: Whether link should work in both directions
20
"""
21
22
class Callback:
23
"""
24
Base callback class for reactive programming patterns.
25
26
Parameters:
27
- source: Source component to watch for changes
28
- target: Target component to update
29
- code: JavaScript or Python code to execute on changes
30
"""
31
```
32
33
### JavaScript Links
34
35
High-performance client-side property linking using JavaScript callbacks.
36
37
```python { .api }
38
class JSCallbackGenerator:
39
"""Generates JavaScript callbacks for client-side property linking"""
40
41
class JSLinkCallbackGenerator:
42
"""Specialized generator for JavaScript property links between components"""
43
```
44
45
## Usage Examples
46
47
### Basic Property Linking
48
49
```python
50
import panel as pn
51
52
# Create components
53
slider = pn.widgets.IntSlider(start=0, end=100, value=50)
54
number_input = pn.widgets.NumberInput(value=50)
55
56
# Link slider value to number input
57
pn.links.Link(slider, number_input, properties={'value': 'value'})
58
59
# Bidirectional linking
60
pn.links.Link(slider, number_input, properties={'value': 'value'}, bidirectional=True)
61
```
62
63
### JavaScript Links for Performance
64
65
```python
66
import panel as pn
67
68
# High-performance client-side linking
69
text_input = pn.widgets.TextInput(value="Hello")
70
markdown = pn.pane.Markdown("Hello")
71
72
# JavaScript link for immediate updates without server roundtrip
73
pn.links.JSLink(text_input, markdown, properties={'value': 'object'})
74
```
75
76
The links system is essential for building responsive applications with complex component interactions and is particularly valuable for performance-critical applications where minimizing server roundtrips is important.