minibus 1.0.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 78

minibus

A library for a minimal synchronous event bus.

Basic Usage

A simple usage example:

import 'package:minibus/minibus.dart';
String EVENT = "myevent";

main() {
  MiniBus bus1 = new MiniBus();
  bus1.subscribe(EVENT, (){print('Hello World!')});
  bus1.post(EVENT);
}

Features and bugs

Please file feature requests and bugs.

Run tests with:

  • pub run test

Check source code formatting:

  • dartfmt -n .

Changelog

1.0.0

  • Refactors and move version to 1.

0.0.5

  • Updates for Dart 2.

0.0.4

  • Minor refactoring and SDK constraint changed.

0.0.3

  • Update to prepare for Dart 2.0.
  • Documentation updated - details and example.

0.0.2

  • Added (optionally) events with data providers.

0.0.1

  • Initial version.

example/minibus_example.dart

// Copyright (c) 2017-2018, daftspaniel. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'package:minibus/minibus.dart';

const EVENT = "Greeting";
const ANOTHER_EVENT = "Goodbye";

void hello() {
  print("\tHello!");
}

void hi() {
  print("\tHi!");
}

void bye() {
  print("\tBye!");
}

main() {
  print('\n * Event with single listener.\n');
  var bus1 = new MiniBus();
  bus1.subscribe(EVENT, hi);
  bus1.post(EVENT);

  print('\n * Event with multiple listeners.\n');
  var bus2 = new MiniBus();
  bus2.subscribe(EVENT, hi);
  bus2.subscribe(EVENT, hello);
  bus2.subscribe(ANOTHER_EVENT, bye);
  bus2.post(EVENT);

  print('\n * See what is connected:\n');
  bus1.report();
  bus2.report();

  print('\n * Get some data with and event:\n');
  var bus3 = new MiniBus();
  int eventValue;
  int provider() {
    return 1234;
  }

  void handler(Function dataProvider) {
    eventValue = dataProvider();
  }

  bus3.subscribe("Test", handler);
  bus3.post("Test", provider);
  print('   event returned ${eventValue}');
  bus3.report();
}

Use this package as a library

1. Depend on it

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


dependencies:
  minibus: ^1.0.0

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 flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:minibus/minibus.dart';
  
Version Uploaded Documentation Archive
1.0.0 Jul 25, 2018 Go to the documentation of minibus 1.0.0 Download minibus 1.0.0 archive
0.0.5 Jul 24, 2018 Go to the documentation of minibus 0.0.5 Download minibus 0.0.5 archive
0.0.4 Sep 28, 2017 Go to the documentation of minibus 0.0.4 Download minibus 0.0.4 archive
0.0.3 Jul 16, 2017 Go to the documentation of minibus 0.0.3 Download minibus 0.0.3 archive
0.0.2 Jun 28, 2017 Go to the documentation of minibus 0.0.2 Download minibus 0.0.2 archive
0.0.1 Jun 24, 2017 Go to the documentation of minibus 0.0.1 Download minibus 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
56
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]
78
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
Dev dependencies
test ^0.12.0