danschultz / frappe

A Dart package for functional reactive programming

Home Page:http://pub.dartlang.org/packages/frappe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reactables should preserve stream type

danschultz opened this issue · comments

The following code is throwing a Uncaught Error: Bad state: Stream has already been listened to. error:

var searchInput = $["search-input"] as TextInputElement;

var onInput = new EventStream(searchInput.onChange)
    .debounce(new Duration(microseconds: 250))
    .map((_) => searchInput.value)
    .distinct();

onInput.forEach((search) => print("searching for $search"));

var suggestions = onInput.flatMapLatest((search) => _queryMovies(search).asStream());

suggestions.forEach((suggestions) => print(suggestions));

Since searchInput.onChange is a broadcast stream, I'd expect that I'd be able to add multiple listeners to the reactable transformation.

FYI I just attempted to upgrade to 0.3.2 but I hit this issue all over the place

Thanks for the report. I'll tackle this next.

These issues should be fixed in the v0.4 branch