# immutable values

**URL:** <https://talk.observablehq.com/t/immutable-values/1769>\
**Category:** Help\
**Created:** [March 15, 2019, 9:19pm UTC](https://talk.observablehq.com/t/immutable-values/1769 "2019-03-15T21:19:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bgits](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgits/32/1707_2.png) [@bgits](https://talk.observablehq.com/u/bgits)\
**Post date:** [March 15, 2019, 9:19pm UTC](https://talk.observablehq.com/t/immutable-values/1769/1 "2019-03-15T21:19:39Z")

</div>

I have a notebook which inputs a value from another notebook to set the default value for a slider which in turn updates that value being displayed from the other notebook. The problem is this is a circular definition.

I’m wondering if it’s possible to have a set of values that are set once and then frozen as immutable, in this case the default value might be set on page load then this circular reference should not be an issue.

Can this be done or planned for?

---

<div class="post-metadata">

**Author:** ![bgchen](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgchen/32/784_2.png) [@bgchen](https://talk.observablehq.com/u/bgchen)\
**Post date:** [March 16, 2019, 1:44am UTC](https://talk.observablehq.com/t/immutable-values/1769/2 "2019-03-16T01:44:08Z")

</div>

Could you share a minimal example pair of notebooks of what you’re trying to do? As far as I can tell, in notebook 1, you have something like this:

> [@bgits](#):
>
> a notebook which inputs a value from another notebook

```js
import {value} from 'notebook-2'

```

which is used to:

> [@bgits](#):
>
> to set the default value for a slider

```js
viewof slider = html`<input type="range" value="${value}">`

```

But I’m not sure I understand what you mean here:

> [@bgits](#):
>
> which in turn updates that value being displayed from the other notebook.

It sounds like there might be something else that you’re importing from notebook 2 that `slider` controls?

In case it helps, note that you can import multiple independent copies of a notebook as long as your import statements use the `with` syntax; e.g. this

```js
import {chart} with {slider as value} from 'notebook-2'

```

imports `chart` from an independent “copy” of notebook 2 (independent of the import that gives us `value` above) with `slider` standing in for `value`…

---

<div class="post-metadata">

**Author:** ![bgits](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgits/32/1707_2.png) [@bgits](https://talk.observablehq.com/u/bgits)\
**Post date:** [March 16, 2019, 10:11am UTC](https://talk.observablehq.com/t/immutable-values/1769/3 "2019-03-16T10:11:31Z")

</div>

Sure. In [https://observablehq.com/@bgits/status-network-combined-utility-values](https://observablehq.com/@bgits/status-network-combined-utility-values)

There is a slider: `dappLocalProbabilityOfFailure` which is then used as `{dappLocalProbabilityOfFailure as probabilityOfFailure} from '@bgits/status-dapp-store-utility-value-exploration'`

However I would like to use `probabilityOfFailure` from `@bgits/status-dapp-store-utility-value-exploration` as the initial value of `dappLocalProbabilityOfFailure` without creating a circular dependency.

---

<div class="post-metadata">

**Author:** ![bgchen](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgchen/32/784_2.png) [@bgchen](https://talk.observablehq.com/u/bgchen)\
**Post date:** [March 16, 2019, 3:26pm UTC](https://talk.observablehq.com/t/immutable-values/1769/4 "2019-03-16T15:26:26Z")

</div>

Hmm, I can’t test this properly because CORS restrictions on your data source break [my fork](https://observablehq.com/compare/18a15dd5dd78531d...ec0dab958316171c) (interestingly enough I guess it works in the compare link), but is what you want achieved by the following?

At the bottom, I import another independent copy of `@bgits/status-dapp-store-utility-value-exploration`

```auto
import {probabilityOfFailure as initProbabilityOfFailure} from '@bgits/status-dapp-store-utility-value-exploration'

```

(This is independent from the other import of that notebook because the other one uses the `import...with` syntax and this one doesn’t.)

Then I edit `viewof dappLocalProbabilityOfFailure`:

```auto
viewof dappLocalProbabilityOfFailure = slider({
  min: 0, 
  max: 1, 
  step: .01, 
  value: initProbabilityOfFailure, 
  title: "Probability of failure for DApp Store", 
  description: "The probabilty that this project in isolation will fail"
})

```
