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

A Property from scan

tosh opened this issue · comments

In the example code below I was trying to produce a Property which represents a click counter of a button.
But upon loading the page in Dartium using chrome dev editor I get the following error. Not sure what I'm doing wrong here, anyone knows?

Exception: Class '_ScanReactable' has no instance method 'asBroadcastStream'.

NoSuchMethodError: method not found: 'asBroadcastStream'
Receiver: Instance of '_ScanReactable'
Arguments: [onCancel: null, onListen: null]

package:frappe/src/event_stream.dart:55
import 'dart:html';
import 'package:frappe/frappe.dart';

void main() {
  EventStream clickStream = new EventStream(querySelector('.frp button').onClick)
      .map((event) => 1);
  window.console.log(clickStream);

  Property count = clickStream.scan(0, combine);

  count.listen((event) => window.console.log(event));
}

int combine(int x, int y) {
  return x + y;
}

I'm using frappe: ">=0.3.0+1 <0.4.0" in the pubspec and DartiumVersion 37.0.2062.0 (291930)

Definitely a bug. You can use .asStream().asBroadcastStream() as a workaround.

Should be fixed now. Thanks for the report!