wire 0.1.6

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

Wire #

Dart publish-subscribe library, with static layer beneath, where responses associated with "keys" called - signals. Simplest possible API - add, remove and send.

const String
    SIGNAL_1 = "SIGNAL_1",
    SIGNAL_ONCE = "SIGNAL_1_ONCE",
    SIGNAL_2 = "SIGNAL_2";
    
  /// SUBSCRIBER EXAMPLE ======================================
  Wire.add(SIGNAL_1, (data) {
    print("> SIGNAL 1 (subscriber 1) -> Hello: " + data);
  });

  Wire.add(SIGNAL_1, (data) {
    print("> SIGNAL 1 (subscriber 2) -> Hello: " + data);
  });

  Wire.send(SIGNAL_1, "World");
  Wire.send(SIGNAL_1, "Dart");
  Wire.send(SIGNAL_1, "Vladimir");
  Wire.remove(SIGNAL_1);
  /// SUBSCRIBER END =========================================

  /// ONCE EXAMPLE ===========================================
  Wire.add(SIGNAL_ONCE, (data) {
    print("> SIGNAL 1 (limit 1) -> Goodbye: " + data);
  }, 1);

  print("\tNo ends: " + Wire.send(SIGNAL_ONCE, "World").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_ONCE, "Dart").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_ONCE, "Vladimir").toString());
  /// ONCE END ===============================================

  Wire.add(SIGNAL_2, (data) {
    print("> SIGNAL 2 -> I do: " + data);
  });

  Wire.add(SIGNAL_2, (data) {
    print("> SIGNAL 2 (limit 2) -> I do: " + data);
  }, 2);

  print("\tNo ends: " + Wire.send(SIGNAL_2, "Code").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_2, "Gym").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_2, "Eat (sometimes)").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_2, "Sleep").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_2, "Repeat").toString());

0.1.5 #

  • Initial version, with base API: add / send / remove

example/wire_example.dart

import 'package:wire/wire.dart';

main() {
  /// SUBSCRIBER EXAMPLE ======================================
  const String
    SIGNAL_1 = "SIGNAL_1",
    SIGNAL_ONCE = "SIGNAL_1_ONCE",
    SIGNAL_2 = "SIGNAL_2";

  Wire.add(SIGNAL_1, (data) {
    print("> SIGNAL 1 (subscriber 1) -> Hello: " + data);
  });

  Wire.add(SIGNAL_1, (data) {
    print("> SIGNAL 1 (subscriber 2) -> Hello: " + data);
  });

  Wire.send(SIGNAL_1, "World");
  Wire.send(SIGNAL_1, "Dart");
  Wire.send(SIGNAL_1, "Vladimir");
  Wire.remove(SIGNAL_1);
  /// SUBSCRIBER END =========================================

  /// ONCE EXAMPLE ===========================================
  Wire.add(SIGNAL_ONCE, (data) {
    print("> SIGNAL 1 (limit 1) -> Goodbye: " + data);
  }, 1);

  print("\tNo ends: " + Wire.send(SIGNAL_ONCE, "World").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_ONCE, "Dart").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_ONCE, "Vladimir").toString());
  /// ONCE END ===============================================

  Wire.add(SIGNAL_2, (data) {
    print("> SIGNAL 2 -> I do: " + data);
  });

  Wire.add(SIGNAL_2, (data) {
    print("> SIGNAL 2 (limit 2) -> I do: " + data);
  }, 2);

  print("\tNo ends: " + Wire.send(SIGNAL_2, "Code").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_2, "Gym").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_2, "Eat (sometimes)").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_2, "Sleep").toString());
  print("\tNo ends: " + Wire.send(SIGNAL_2, "Repeat").toString());
}

Use this package as a library

1. Depend on it

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


dependencies:
  wire: ^0.1.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


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

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

Format lib/src/layer.dart.

Run dartfmt to format lib/src/layer.dart.

Format lib/src/wire.dart.

Run dartfmt to format lib/src/wire.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.4.0 <3.0.0
Dev dependencies
test ^1.6.0