Avalanche events

  • Stream for decouple many objects
  • Simple subscription on object events
  • Work both, on client and server

All you need is stream

Build Status

c9 - editor


library example_library;

import 'dart:async';

import 'package:avalanche_events/avalanche_events.dart';

/// Extend class
class BestClass extends AvalancheEvents {}
/// Or extend Object with mixins
class OtherBestClass extends Object with NotifyMixin, ObservableMixin {}

void main() {
    BestClass bestClass = new BestClass();
    OtherBestClass otherBestClass = new OtherBestClass();
    
    bestClass.observable(otherBestClass);
    
    /// Just listen self stream
    otherBestClass.on('Event from bestClass', (bool eventData){
        print(eventData); // is true
    });
    
    bestClass.dispatchEvent('Event from bestClass', true);
}

Details

GRASP - wiki - Low coupling - wiki

Observer Design Pattern - sourcemaking

Mediator Design Pattern - sourcemaking

Libraries

avalanche_events