react-native-training-chat-server

2.0.0 • Public • Published

react-native-training-chat-server

A client library for a chat server to be used in React Native training

API

send({ channelName, sender, message })

Takes a single parameter with three properties: channel name, sender name and a message text. Returns a Promise.

import { send } from 'react-native-training-chat-server';
 
send({
  channel: "ChannelName",
  sender: "Your Name",
  message: "Anything you'd like to say"
});

subscribe(channelName, callback)

Callback is called every time new messages arrive to chat

import { subscribe } from 'react-native-training-chat-server';
 
subscribe("ChannelName", messages => {
  messages.forEach(message => {
    console.log(`${message.sender}${message.message}`);
  })
});

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-training-chat-server

Weekly Downloads

1

Version

2.0.0

License

MIT

Last publish

Collaborators

  • jevakallio