funkia / turbine

Purely functional frontend framework for building web applications
MIT License
685 stars 27 forks source link

input value bug #86

Closed stevekrouse closed 5 years ago

stevekrouse commented 5 years ago

This example expects the inputs to mirror each other. This behavior works in the beginning. You can pick either input box and change the value and it will mirror in the other. But if you modify the other, it won't change in the other one. And if you go back to the first one, it won't change the other anymore. Yet, when you put the behavior in another element (such as an span), it reflects that the stream is working correctly.

import { combine, sample, changes, stepper } from "@funkia/hareactive";
import { runComponent, elements, modelView, fgo, go } from "@funkia/turbine";
const { input, span } = elements;

const tempModel = fgo(function*({ val1_, val2_ }) {
  const v = yield sample(stepper(0, combine(changes(val1_), changes(val2_))));
  return { v };
});
const tempView = ({ v }) =>
  go(function*() {
    yield span(v);
    const { inputValue: val1_ } = yield input({ value: v });
    const { inputValue: val2_ } = yield input({ value: v });
    return { val1_, val2_ };
  });
const temp = modelView(tempModel, tempView);

runComponent("#app", temp());

https://codesandbox.io/s/rrwlvx41pq

paldepind commented 5 years ago

This is indeed a bug and not expected behavior.

stevekrouse commented 5 years ago

nvm, this works with the most recent versions of turbine and hareactive

paldepind commented 5 years ago

Great!