| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Reactive widget models whose state is synchronised through Conflict-free Replicated Data Type (CRDT) via the yrs package.
make_comm_widget() defines an R6 class whose named attributes are backed by a shared ydoc. Constructing an instance opens a Jupyter comm and keeps the attributes in sync with the connected frontend.
library(ywidgets)
# Define a widget class with two synced attributes.
Counter <- make_comm_widget("Counter", label = "", count = 0L)
# Constructing opens the comm and starts syncing. Run this in an xeus-r kernel.
w <- Counter$new(label = "clicks")
# Attributes are active bindings: read and write them directly.
w$count
w$count <- w$count + 1L
# React to changes coming from the frontend.
w$connect(count = function(value) {
message("count is now ", value)
})
Writes to an attribute update the ydoc and propagate to the frontend; remote changes update the attribute and fire the callbacks registered with $connect().
| Back | FazBrowse Home | New Git URL |