Skip to content

Commit

Permalink
Add bindings for transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Oct 14, 2024
1 parent 980de7c commit d0061a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vendor/brr_lwd_ui/bindings/yjs/doc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,8 @@ module Doc = struct
Jv.call t "getMap" [| Jv.of_string name |] |> Map.of_jv

let make () = Jv.new' global [||]

let transact t f =
let callback = Jv.callback ~arity:1 f in
Jv.call t "transact" [| callback |] |> ignore
end
4 changes: 4 additions & 0 deletions vendor/brr_lwd_ui/bindings/yjs/doc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ module Doc : sig
val make : unit -> t
val get_array : t -> string -> Array.t
val get_map : t -> string -> Map.t

val transact : t -> (unit -> unit) -> unit
(** Bundles multiple operations into one transaction. Observer calls and the
update event will be called only once per transaction. *)
end

0 comments on commit d0061a4

Please sign in to comment.