event_stream 0.3.2

  • README.md
  • Example
  • Installing
  • Versions
  • 62

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<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)); }

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

main() { var c = new ClassWithEvents(); c.onPropertyChanged.listen((PropertyChangedEventArgs<String> args) => print('changed: name=${args.propertyName} value=${args.value}')); c.onClosed.listen((_) => print('closed')); c.someProperty = "test"; c.close(); }


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();
}

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

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages 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';
        
Version Uploaded Documentation Archive
0.3.2 Nov 1, 2013 Go to the documentation of event_stream 0.3.2 Download event_stream 0.3.2 archive
0.3.1 Jul 18, 2013 Go to the documentation of event_stream 0.3.1 Download event_stream 0.3.1 archive
0.2.1 Apr 26, 2013 Go to the documentation of event_stream 0.2.1 Download event_stream 0.2.1 archive
0.1.1 Jan 31, 2013 Go to the documentation of event_stream 0.1.1 Download event_stream 0.1.1 archive
0.1.0 Jan 31, 2013 Go to the documentation of event_stream 0.1.0 Download event_stream 0.1.0 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
68 / 100
Health:
Code health derived from static analysis. [more]
94 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0 / 100
Overall score:
Weighted score of the above. [more]
62

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:event_stream/event_stream.dart.

Suggestions

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Use constrained dependencies.

    The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: unittest.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
unittest any 0.12.3 0.12.4+1
Transitive dependencies
analyzer 0.25.0+1 0.31.0+1
args 0.13.7 1.3.0
async 1.13.3 2.0.3
barback 0.15.2+14
charcode 1.1.1
collection 1.14.5
convert 2.0.1
crypto 0.9.1 2.0.2+1
glob 1.1.5
http 0.11.3+16
http_multi_server 1.3.2 2.0.4
http_parser 0.0.2+8 3.1.1
matcher 0.12.0+2 0.12.1+4
mime 0.9.6
package_config 1.0.3
package_resolver 1.0.2
path 1.5.1
pool 1.3.4
pub_semver 1.3.2
shelf 0.6.3 0.7.2
shelf_static 0.2.7
shelf_web_socket 0.0.1+5 0.2.2
source_map_stack_trace 1.1.4
source_maps 0.10.4
source_span 1.4.0
stack_trace 1.9.1
string_scanner 0.1.5 1.0.2
test 0.12.3+9 0.12.30+1
typed_data 1.1.5
watcher 0.9.7+7
yaml 2.1.13