calmm-js / kefir.atom

Composable and decomposable reactive state with lenses and Kefir
MIT License
51 stars 6 forks source link

`atom.toPromise()` is always pending #10

Closed rikutiira closed 6 years ago

rikutiira commented 6 years ago

Seems like there's some issue with Kefir's .toPromise() when working with atoms, as the returned promise is always pending.

U.atom('foo').toPromise() // pending U.atom('foo').toProperty().toPromise() // pending U.atom('foo').toProperty(() => 'bar').toPromise() // pending

polytypic commented 6 years ago

Hmm... I think that works as expected. From Kefir's docs on toPromise:

The promise will be fulfilled or rejected at the moment source observable ends, with the latest value or error.

Atoms usually do not end.

polytypic commented 6 years ago

Would U.atom('foo').take(1).toPromise() work in your use case?

rikutiira commented 6 years ago

Yeah, you are right, I remembered that it would take the current value of observable. Should have checked Kefir docs for clarity, sorry!