tcd-message-center
TypeScript icon, indicating that this package has built-in type declarations

0.8.2 • Public • Published

TCD Message Center

This is a backend in front-end library for TCD for messaging.

Install

Run the following command in your project

yarn add tcd-message-center # or npm install tcd-message-center

Usage

Import the main class which is MessageCenter.

import { MessageCenter } from "tcd-message-center"

Create an instance of MessageCenter

const messageCenter = new MessageCenter({
  auth: firebase.auth(),
  storage: firebase.storage(),
  functions: firebase.functions(),
  realtime: firebase.database()
})

Retrieve Chat objects from this messageCenter object.

const chats: Chat[] = messageCenter.getChats(10, 0); // limit, offset

Now, you can start your work on each Chat object whenever that object is ready.

import {ChatEvents, MessageEvents} from "tcd-message-center"
chat.on(ChatEvents.READY, () => {
  //your code...
})

These ChatEvents, MessageEvents and CountEvents are available on Chat object.

CountEvents.Unread is also available on MessageCenter object to listen for total unread count on all chats.

API Docs

Class Chat is an EventEmitter class. So you can trigger and listen for events on any Chat object.

Readme

Keywords

none

Package Sidebar

Install

npm i tcd-message-center

Weekly Downloads

5

Version

0.8.2

License

MIT

Unpacked Size

506 kB

Total Files

43

Last publish

Collaborators

  • mukarramishaq