# is there a way to prevent invalidation for a specific cell?

**URL:** <https://talk.observablehq.com/t/is-there-a-way-to-prevent-invalidation-for-a-specific-cell/4416>\
**Category:** Help\
**Created:** [January 1, 2021, 5:40pm UTC](https://talk.observablehq.com/t/is-there-a-way-to-prevent-invalidation-for-a-specific-cell/4416 "2021-01-01T17:40:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rabelais88](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/rabelais88/32/4112_2.png) [@rabelais88](https://talk.observablehq.com/u/rabelais88)\
**Post date:** [January 1, 2021, 5:40pm UTC](https://talk.observablehq.com/t/is-there-a-way-to-prevent-invalidation-for-a-specific-cell/4416/1 "2021-01-01T17:40:19Z")

</div>

It seems change on `mutable` data causes invalidation for all cells. I can see why it’s important; the data-flow of an observable note is reactive. However, for a project that I am working on, I want to use `.update()` with `mutable` data.

The chart is svg heavy at the moment, so re-rendering all data(recreating all svg elements) would cause a significant performance drop. I am aware it is possible to use `.update()`, if the data is defined as a non-reactive data. The problem is that the data is really complex so it would be very unwise to put it as a non-reactive.

I’ve tried to illustrate what I have in mind with this observable note:

> **[Testing with mutable object](https://observablehq.com/@rabelais/testing-with-mutable-object)**
>
> .update() does not work with mutable data, because mutable triggers invalidation. this example illustrates that.

is there a way to prevent invalidation for a specific cell, so that I can observe the data and use it for `.update()`?

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [January 1, 2021, 11:58pm UTC](https://talk.observablehq.com/t/is-there-a-way-to-prevent-invalidation-for-a-specific-cell/4416/2 "2021-01-01T23:58:43Z")

</div>

I recommend exposing an _update_ method for your chart as described in Learn D3: Animation.

> **[Learn D3: Animation](https://observablehq.com/@d3/learn-d3-animation)**
>
> Unlike graphics drawn on paper, computer graphics needn’t be static; like Frankenstein’s monster, they can come alive through animation! ✨ The line chart above reveals progressively. This is somewhat gratuitous—motion should be used sparingly as it...

Here’s a suggestion applying the technique to your notebook:

> **[Comparing ‘Testing with mutable object’ by sungryeol park(max) to ‘Testing...](https://observablehq.com/compare/03c2aa25299a94b3@146...a5f1f668dda40239@163)**
>
> A comparison of two Observable notebooks.

Note that for this technique to work, you must ensure that neither _chart_ nor any of its upstream dependencies (such as _scaleRadius_ and _scaleX_) reference _data_; if they do, then assigning to _mutable data_ will cause the _chart_ to be redrawn from scratch rather than transitioning. That’s why in my suggestion I mutate the domains of the scales inside _chart_.update, but it’d probably be slightly cleaner to make those local variables to the _chart_ cell rather than having them as cells. (You might find the [minimap](https://observablehq.com/@observablehq/introducing-visual-dataflow) helpful for tracing dependencies.)

You can also opt-out of “reacting” to the mutable data changing by referencing `mutable data` instead of `data`.

---

<div class="post-metadata">

**Author:** ![rabelais88](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/rabelais88/32/4112_2.png) [@rabelais88](https://talk.observablehq.com/u/rabelais88)\
**Post date:** [January 2, 2021, 6:39am UTC](https://talk.observablehq.com/t/is-there-a-way-to-prevent-invalidation-for-a-specific-cell/4416/3 "2021-01-02T06:39:15Z")

</div>

Thank you for your kind answer. 🙇‍♂️ I couldn’t think of such technique. The attached notes are also a tremendous help for me.

happy new year!
