# how to resolve a conundrum of promises and Observable inputs?

**URL:** <https://talk.observablehq.com/t/how-to-resolve-a-conundrum-of-promises-and-observable-inputs/4476>\
**Category:** Help\
**Created:** [January 19, 2021, 3:13pm UTC](https://talk.observablehq.com/t/how-to-resolve-a-conundrum-of-promises-and-observable-inputs/4476 "2021-01-19T15:13:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [January 19, 2021, 3:13pm UTC](https://talk.observablehq.com/t/how-to-resolve-a-conundrum-of-promises-and-observable-inputs/4476/1 "2021-01-19T15:13:37Z")

</div>

I am trying to use Observable as an interface for editing data and have encountered a challenge using Observable inputs due to their behavior as promises. I would like to both understand it and adjust for it.

Using [`@jashkenas/inputs`](https://observablehq.com/@jashkenas/inputs) I created a series of inputs for a survey. If I supply any value to the input that is not among its ‘options’, the input returns a promise (Part 1, below). [**Edit:** This looks like an issue particularly for radio inputs]

Since I need these values to resolve in order for a linked cell to also return a value (rather than a promise), I try wrapping the input with `Object.assign( [**input**] ), {value: Promise.resolve("")})`. This is great. It gives me the ability to supply data values into the input, and the input is _aware_ that it’s receiving an initial value that matches an option (it looks like ‘yes’ is checked’. However the input is also _self-aware_—it knows that it is a promise, and it knows whether or not it has been invoked—so if a person doesn’t click, the value of the input cell will returns the value set using `Promise.resolve("")` rather than the value supplied into it (Part 2, below).

https://observablehq.com/embed/aa1dcb716feba52c?cell=gathered_data&cell=promise&cell=viewof+toggle&cell=toggle_view&cell=test_data&cell=blank&cell=viewof+other_toggle&cell=other_toggle_view&cell=other_test_data

**Ouch!** This means that when I try to group my inputs and save them again, any pre-exiting values that _appear_ to be supplied will get overwritten by whatever value I am using to resolve my promise. The only way around this that I can currently see is to create (and then hide) an input that matches my “blank” value, but this doesn’t seem like “the right” way.

Any tips for a good way around this?

Although it’s linked in the frame above, here’s a notebook link for easier clicking:

> **[Link Values through Input](https://observablehq.com/d/aa1dcb716feba52c)**
>
> Part 1, Always a promise: Part 2, Not my value:

* * *

**Note:** Interacting with the Part 2 toggle will change its value, at which point the value is passed to `gathered_data`. My issue is that the ‘resolved promise’ value overwrites the supplied value. If you interact with Part 2 before Part 1, you will not see this change in the `gathered_data` object, since it will be waiting to resolve. Watch what happens in `other_toggle_view` under Part 2 before and after you click the toggle.

* * *

**Observation:** It’s looking like the issue is particular to the `radio` input

---

<div class="post-metadata">

**Author:** ![tomlarkworthy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tomlarkworthy/32/5940_2.png) [@tomlarkworthy](https://talk.observablehq.com/u/tomlarkworthy)\
**Post date:** [January 19, 2021, 6:25pm UTC](https://talk.observablehq.com/t/how-to-resolve-a-conundrum-of-promises-and-observable-inputs/4476/2 "2021-01-19T18:25:03Z")

</div>

The current behaviour of a radio is to not resolve until the user actually chooses something. In 90% of cases this makes sense. I would expect setting the value to work for the initial value, maybe it’s a missing feature, but a work around is to build the input and set the value manually from the outside.

```auto
viewof r1 = {
  const input = radio({
    title: 'Contact Us',
    description: 'Please select your preferred contact method',
    options: [

      { label: 'By Email', value: 'email' },
      { label: 'By Phone', value: 'phone' },
      { label: 'By Pager', value: 'pager' },
      { label: 'By Pager', value: 'pager' },
    ],
  })
  input.value = "yo"
  return input
}

```

---

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [January 19, 2021, 6:29pm UTC](https://talk.observablehq.com/t/how-to-resolve-a-conundrum-of-promises-and-observable-inputs/4476/3 "2021-01-19T18:29:28Z")

</div>

Thank you, Tom. This works! And _so_ much better than creating a dummy option that I don’t wish to show !
