Skip to content

Instantly share code, notes, and snippets.

@thorseraq
Created April 12, 2023 01:57
Show Gist options
  • Select an option

  • Save thorseraq/ed8c50f5098532697b72e62be6bf8a31 to your computer and use it in GitHub Desktop.

Select an option

Save thorseraq/ed8c50f5098532697b72e62be6bf8a31 to your computer and use it in GitHub Desktop.
use yrs::{DeepObservable, Doc, Map, Transact};
fn main() {
let doc = Doc::new();
let mut block = doc.get_or_insert_map("block");
let sub = block.observe_deep(move |_trx, _e| {
println!("subscribe -> observe_deep");
});
// drop(sub); // drop sub will lose observation
let mut trx = doc.transact_mut();
block.insert(&mut trx, "key", "value");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment