event_stream 0.3.2

event_stream #

Introduction #

Makes it easier to expose custom events in Dart using the Stream API.

Getting Started #

1. Add the following to your project's pubspec.yaml and run


dependencies: event_stream: any


2\. Add the correct import for your project.

import 'package:event_stream/event_stream.dart';


## Example ##

import 'package:event_stream/event_stream.dart';

import 'dart:async';

class ClassWithEvents implements NotifyPropertyChanged { String _someProperty;

final EventStream

final EventStream _onClosedEvent = new EventStream(); Stream get onClosed => _onClosedEvent.stream;

String get someProperty => _someProperty; set someProperty(String value) { _someProperty = value; _onPropertyChangedEvent.signal(new PropertyChangedEventArgs('someProperty', value)); }

close() { _onClosedEvent.signal(); } }

main() { var c = new ClassWithEvents(); c.onPropertyChanged.listen((PropertyChangedEventArgs


example/example.dart

import 'package:event_stream/event_stream.dart';

import 'dart:async';

class ClassWithEvents implements NotifyPropertyChanged {
  String _someProperty;
  String _someOtherProperty;
  int _someIntProperty;
  
  final EventStream<PropertyChangedEventArgs> _onPropertyChangedEvent = new EventStream<PropertyChangedEventArgs>();
  Stream<PropertyChangedEventArgs> get onPropertyChanged => _onPropertyChangedEvent.stream;
  
  final EventStream _onClosedEvent = new EventStream();
  Stream get onClosed => _onClosedEvent.stream;
  
  String get someProperty => _someProperty;
  set someProperty(String value) {
    _someProperty = value;
    _onPropertyChangedEvent.signal(new PropertyChangedEventArgs('someProperty', value));
  }
  
  String get someOtherProperty => _someOtherProperty;
  set someOtherProperty(String value) {
    _someOtherProperty = value;
    _onPropertyChangedEvent.signal(new PropertyChangedEventArgs('someOtherProperty', value));
  }
  
  int get someIntProperty => _someIntProperty;
  set someIntProperty(int value) {
    _someIntProperty = value;
    _onPropertyChangedEvent.signal(new PropertyChangedEventArgs('someIntProperty', value));
  }
  
  close() {
    _onClosedEvent.signal();
  }
}

main() {
  var c = new ClassWithEvents();
  c.onPropertyChanged.listen((PropertyChangedEventArgs<String> args) => print('listen1: name=${args.propertyName} value=${args.value} type=${args.value.runtimeType}'));
  c.onPropertyChanged.listen((PropertyChangedEventArgs<String> args) => print('listen2: name=${args.propertyName} value=${args.value} type=${args.value.runtimeType}'));
  c.onClosed.listen((_) => print('closed1'));
  c.onClosed.first.whenComplete(() => print('first closed'));
  c.someProperty = "test1";
  c.someOtherProperty = "test1";
  c.someProperty = "test2";
  c.someOtherProperty = "test2";
  c.someIntProperty = 1;
  c.close();
  c.close();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  event_stream: ^0.3.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:event_stream/event_stream.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.