Re: [whatwg/dom] Disconnect single target instead of all (#126)

trusktr left a comment (whatwg/dom#126)

I would really like to have this to drastically simplify my code (going from one MO per root to a single MO for all roots), without the [ordering problem](https://github.com/whatwg/dom/issues/1105).

It seems like a tie for something like these two options:

**Option 1:** `mo.unobserve(el)` could stop observation for an element, and immediately remove its records from the queue.

**Option 2:** or it could leave the queue as is, and simply stop adding any new records to the queue.

With either of those two options, someone could use `mo.takeRecords()` to process all changes for the unobserved target, but this has the implication that all records for all other targets would also have to be handled at that time. Not a huge deal, but maybe not the best for performance if further mutations will still happen and the future callback would otherwise save on work to be done.

It could be possible that we could *later* introduce a new `mo.takeRecords(target)` signature for taking out the records of a specific targets, alleviating any issue with `mo.takeRecords()` taking out all records.

With this in mind, my preference is option **(1)** because it avoids surprises (f.e. "why did my MO still observe the target when I already unobserved it?"). Plus I hope we may be able to add `mo.takeRecords(el)` later to help make things even easier.

I can live with either option honestly, having either option would help greatly simplifying for cross-root use cases regardless.

### How can we break this tie, and move forward?

Let's try this:

From the options above, React with 😄 for option **(1)**, or 🎉 for option **(2)**.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/126#issuecomment-2833747695
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/126/2833747695@github.com>

Received on Monday, 28 April 2025 00:54:15 UTC