wire 0.1.6 copy "wire: ^0.1.6" to clipboard
wire: ^0.1.6 copied to clipboard

outdated

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

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());
3
likes
0
pub points
15%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on wire