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

Add a public non-factory constructor for Property

danschultz opened this issue · comments

It's not possible to sub-class Property from a non frappe library.

class Property<T> extends Reactable<T> {
  Property._(Stream<T> stream, bool hasInitialValue, [T initialValue]) {
    ...
  }

  Property(Stream<T> stream) => this._(stream, false);
  Property.withInitialValue(T initialValue, Stream<T> stream) => this._(stream, true, initialValue);
}

Deprecate factory constructors for Property.fromStream() and Property.fromStreamWithInitialValue().

👍 for the feature and the discussion you guys had #40

@danschultz I'm thinking about sending a pr. do you have a guideline I should follow?

@alexvbush, my plan was to add two new non-factory constructors Property(Stream<T> stream) and Property.withInitialValue(T initialValue, Stream<T> stream). This API is more inline with how the EventStream's constructor works.

Thanks for considering making a contribution. It's much appreciated!