
import 'package:event_bus/event_bus.dart';
import '../models/index.dart';

class Events {
  static EventBus _bus;

  static void init() {
    _bus = new EventBus();
  }

  static void fire(dynamic event) {
    _bus.fire(event);
  }

  static Stream<T> on<T>() {
    return _bus.on<T>();
  }
}

class NotifyMessage {
  String payload;
  NotifyMessage(this.payload);
}

class ClearUnread {
  String uid;
  ClearUnread(this.uid);
}

class UserOnline {
  UserInfo user;
  UserOnline(this.user);
}

class UserList {
  List<UserInfo> users = new List<UserInfo>();
  UserList(List<dynamic> list) {
    for(var item in list) {
      users.add(UserInfo.fromJson(item));
    }
  }
}

class UserMessage {
  HttpMessage message;
  UserMessage(this.message);
}