blix_signals 0.3.2

  • Installing
  • Versions
  • 0

Build Status

Signals for Dart

Signals are a light-weight, strongly-typed way to implement the observer pattern. They allow you to explicitly define the messages your objects provide, without relying on metadata or documentation.

The Signal object at a basic level is a list of methods to be invoked when the Signal is dispatched.

To get started, first add blix_signals to your pubspec.yaml

  blix_signals: any

Usage Example:

import 'package:blix_signals/signals.dart';

class MilkEvent {
	num amount;
	num duration;
	MilkEvent(this.amount, this.duration);

abstract class IMilkable {
	ISignal<MilkEvent> get milked;

class Cow implements IMilkable {
	Signal<MilkEvent> _milked = new Signal<MilkEvent>();

	ISignal<MilkEvent> get milked => _milked;

	void milk() {
		if (_milked.isNotEmpty) {
			_milked.dispatch(new MilkEvent(1, 1));

class DeliveryPerson {
	void watchMilkable(IMilkable milkable) {
		milkable.milked.add((MilkEvent e) => fillBottle(e.amount));

	void fillBottle(int amount) {
		print("Added ${amount} milk");

void main() {
	var cow = new Cow();
	var deliveryPerson = new DeliveryPerson();
	cow.milk(); // added 1 milk

Three conventions should be pointed out:

  1. The signal is described in past tense.

  2. The dispatch is surrounded by an isNotEmpty check. This is only important for performance if the message requires work to be done. That is, if the message requires a new object to be created, it is best to optimize for the case if there are no handlers.

  3. The exposed interface is using ISignal instead of Signal. The ISignal interface does not expose the dispatch(T) function. This is because it's generally a bad practice to broadcast a message on behalf of another object.

1. Depend on it

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

  blix_signals: "^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:blix_signals/signal.dart';

import 'package:blix_signals/signals.dart';
Version Uploaded Documentation Archive
0.3.2 Nov 14, 2013 Go to the documentation of blix_signals 0.3.2 Download blix_signals 0.3.2 archive
0.3.1 Oct 27, 2013 Go to the documentation of blix_signals 0.3.1 Download blix_signals 0.3.1 archive
0.3.0 Oct 27, 2013 Go to the documentation of blix_signals 0.3.0 Download blix_signals 0.3.0 archive
0.2.2 Oct 26, 2013 Go to the documentation of blix_signals 0.2.2 Download blix_signals 0.2.2 archive
0.2.1 Oct 26, 2013 Go to the documentation of blix_signals 0.2.1 Download blix_signals 0.2.1 archive
0.2.0 Oct 26, 2013 Go to the documentation of blix_signals 0.2.0 Download blix_signals 0.2.0 archive
0.1.1 Oct 25, 2013 Go to the documentation of blix_signals 0.1.1 Download blix_signals 0.1.1 archive
0.1.0 Oct 25, 2013 Go to the documentation of blix_signals 0.1.0 Download blix_signals 0.1.0 archive


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

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

  • tool failures on Jan 21, 2018
  • Dart: 2.0.0-dev.15.0
  • pana: 0.10.0


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


Detected platforms: unsure

Error(s) prevent platform classification.


  • Fix lib/signal.dart.

    Strong-mode analysis of lib/signal.dart failed with the following error:

    line: 157 col: 43
    Type parameter bound types must be instantiated.

  • Fix platform conflicts.

    Make sure none of the libraries use mutually exclusive dependendencies.

  • Maintain

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

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 1 error(s) and 0 warning(s).

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • 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.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use blix_signals.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=0.7.6
Dev dependencies
benchmark_harness any
unittest any