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 _onPropertyChangedEvent = new EventStream(); Stream 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 args) => print('changed: name=${args.propertyName} value=${args.value}')); c.onClosed.listen((_) => print('closed')); c.someProperty = "test"; c.close(); }


1. Depend on it

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

dependencies:
  event_stream: 

2. Install it

You can install packages from the command line:

$ pub get

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

About

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

Author

Email eric@codesmithtools.com Eric J. Smith

Homepage

github.com/ejsmith/event_stream

Documentation

www.dartdocs.org/documentation/event_stream/0.3.2/

Source code (hyperlinked)

www.crossdart.info/p/event_stream/0.3.2/

Uploader

eric@codesmithtools.com

Share