# FILE: pages/changelog/v1.8.0.mdx

---
version: "v1.8.0"
title: "Release Loro v1.8.0"
date: 2025/09/22
---

Events now fire **synchronously**

In the JavaScript package `loro-crdt@1.8.0`, we changed event emission from **âafter a microtaskâ** to **synchronous** dispatch. This makes event handling simpler and less errorâprone.

### Why we changed it

Historically, the JS binding emitted events **after a microtask**. The reason was to avoid Rust borrow/aliasing issues: if an event triggered inside `doc.commit()` reâentered the same `doc`, Rust could panic because `commit()` holds a borrow and reusing the object would violate borrowing rules. Deferring events to a microtask avoided that reâentrancy. (Background: Loroâs JS API exposes subscriptions via `doc.subscribe(...)`; the docs note that events used to arrive after a microtask. ([Loro][1]))

However, this deferral made app logic fragile. There was a window between the mutation and the event callback. Example: the app receives the event from CRDT âdelete the 3rd character of `Hi!`â, but during the microtask gap the app state changed `Hi!` â `Hi`. When the deferred event arrives, applying a âdelete index 2â delta can be wrong. In practice, users had to maintain an awkward invariant: **donât mutate the app state during that microtask** if you consume delta updates.

### Whatâs new in 1.8.0

Events are now **dispatched synchronously**âthat is, your listeners run **before** the topâlevel JS call (e.g., `doc.commit()`) returns. To keep this safe with Rustâs borrowing:

- We keep a **global queue** of âpending (listener, event)â pairs.
- JS wrappers decorate APIs that can borrow the Rust doc (e.g., `commit`, import/export, checkout).
- The wrapper calls into WASM/Rust, **returns from the borrow**, then **flushes the queue** and clears it.
- Because callbacks run **outside** the borrowed region, listeners can freely call `doc` APIs without triggering borrow violations.

### What this means for your app

- **Simpler state updates.** No more microtask gap; event ordering matches your mutation order.
- **Fewer footguns with deltas.** You no longer need to uphold âdonât touch the doc during the microtaskâ when applying deltaâstyle updates.
- **Listeners can still safely use `doc`.**