Home Reference Source

Function

Static Public Summary
public

Avatar(props: Object): Object

Renders the chat bot's avatar along with a status indicator.

public

AvatarContainer(objectPattern: {"AvatarComponent": *, "connection": *, "typing": *}): *

public

Button(param: Object): Object

A simple button component

public

ButtonContainer(objectPattern: {"children": *}): *

public

ChatContainer(objectPattern: {"theme": *, "connection": *}): *

public

Fade(objectPattern: {"children": *, ...props: Object})

public

An image

public

Input(param: Object): Object

A simple text Input component.

public

InputArea(objectPattern: {"InputComponent": *, "submitHandler": *, "inputExpected": *, "MenuComponent": *, "CheckboxMenuComponent": *, "buttons": *}): *

public

Menu(param: Object): Object

A menu listing several items.

public

Message(objectPattern: {"page": *, "isLocal": *, "ImageComponent": *, "InputComponent": *, "MessageComponent": *, "TextComponent": *, "ButtonComponent": *, "submitHandler": *}): undefined[]

public

MessageContainer(objectPattern: {"userId": *, "type": *, "children": *, "layout": *, "origin": *, "pages": *, ...rest: Object}): *

public

The main react component for React Web Chat

public

A typing indicator component

public

attempted(_: *): {type: CONNECTION_ATTEMPTED}

Sets connection to attempted

public

Async action creator: Adds a new message after a delay of 1200 milliseconds.

public

dropped(_: *): {type: CONNECTION_DROPPED}

Sets connection to offline

public

established(_: *): {type: CONNECTION_ESTABLISHED}

Sets connection to established

public

Automatically dispatches custom events whenever a redux action is dispatched.

public

getLatestRemote(messages: Array)

Returns the latest remote message

public

listening(_: *): {type: CONNECTION_LISTENING}

Sets connection to listening

public

messageAdd(message: object): {type: MESSAGE_ADD}

Action creator: Adds a message to the store.

public

Async action creator: Dispatched when a message is received from the server.

public

messageSend(message: object): function()

Async action creator: Dispatched when a message is received from the server.

public

remoteMessage(message: Object)

Checks if a message belongs to remote

Static Public

public Avatar(props: Object): Object source

Renders the chat bot's avatar along with a status indicator.

Params:

NameTypeAttributeDescription
props Object
props.avatar string

A url to an image to use as the avatar.

props.connecting boolean

A state variable indicating that the chat app is busy attempting a connection to the server.

props.established boolean

A state variable indicating that the chat server is online and the handshake was successful.

props.offline boolean

A state variable indicating that the chat server is offline.

props.typing boolean

A state variable indicating that the chat app is currently simulating "typing..."

Return:

Object

React component

public AvatarContainer(objectPattern: {"AvatarComponent": *, "connection": *, "typing": *}): * source

Params:

NameTypeAttributeDescription
objectPattern {"AvatarComponent": *, "connection": *, "typing": *}
  • default: {"AvatarComponent":null,"connection":null,"typing":null}

Return:

*

public Button(param: Object): Object source

A simple button component

Params:

NameTypeAttributeDescription
param Object
param.text number

text to be rendered inside button.

param.onClick function(e: Object)

click handler function

Return:

Object

React component

public ButtonContainer(objectPattern: {"children": *}): * source

Params:

NameTypeAttributeDescription
objectPattern {"children": *}
  • default: {"children":null}

Return:

*

public ChatContainer(objectPattern: {"theme": *, "connection": *}): * source

Params:

NameTypeAttributeDescription
objectPattern {"theme": *, "connection": *}
  • default: {"theme":null,"connection":null}

Return:

*

public Fade(objectPattern: {"children": *, ...props: Object}) source

Params:

NameTypeAttributeDescription
objectPattern {"children": *, ...props: Object}
  • default: {"children":null,"props":{}}

public ImageComponent(param: Object): Object source

An image

Params:

NameTypeAttributeDescription
param Object
param.url string

image url

param.width number

width of the image in pixels

param.height number

height of the image in pixels

Return:

Object

React component

public Input(param: Object): Object source

A simple text Input component.

Params:

NameTypeAttributeDescription
param Object
param.value string | number

the input's value.

param.submitHandler function(text: string)

submit handler function. This will send a message to the server using data supplied as parameter

Return:

Object

React component

public InputArea(objectPattern: {"InputComponent": *, "submitHandler": *, "inputExpected": *, "MenuComponent": *, "CheckboxMenuComponent": *, "buttons": *}): * source

Params:

NameTypeAttributeDescription
objectPattern {"InputComponent": *, "submitHandler": *, "inputExpected": *, "MenuComponent": *, "CheckboxMenuComponent": *, "buttons": *}
  • default: {"InputComponent":null,"submitHandler":null,"inputExpected":null,"MenuComponent":null,"CheckboxMenuComponent":null,"buttons":null}

Return:

*

public Menu(param: Object): Object source

A menu listing several items. (single choice)

Params:

NameTypeAttributeDescription
param Object
param.items Array<Object>

The menu items to be displayed

param.submitHandler function(text: string)

submit handler function. This will send a message to the server using data supplied as parameter

Return:

Object

React component

public Message(objectPattern: {"page": *, "isLocal": *, "ImageComponent": *, "InputComponent": *, "MessageComponent": *, "TextComponent": *, "ButtonComponent": *, "submitHandler": *}): undefined[] source

Params:

NameTypeAttributeDescription
objectPattern {"page": *, "isLocal": *, "ImageComponent": *, "InputComponent": *, "MessageComponent": *, "TextComponent": *, "ButtonComponent": *, "submitHandler": *}
  • default: {"page":null,"isLocal":null,"ImageComponent":null,"InputComponent":null,"MessageComponent":null,"TextComponent":null,"ButtonComponent":null,"submitHandler":null}

Return:

undefined[]

public MessageContainer(objectPattern: {"userId": *, "type": *, "children": *, "layout": *, "origin": *, "pages": *, ...rest: Object}): * source

Params:

NameTypeAttributeDescription
objectPattern {"userId": *, "type": *, "children": *, "layout": *, "origin": *, "pages": *, ...rest: Object}
  • default: {"userId":null,"type":null,"children":null,"layout":null,"origin":null,"pages":null,"rest":{}}

Return:

*

public ReactWebChatComponent(params: Object): Object source

import {ReactWebChatComponent} from 'react-web-chat/src/index.js'

The main react component for React Web Chat

Params:

NameTypeAttributeDescription
params Object

An object containing configuration parameters

params.theme Object

Custom theme

params.url Object

Chat server url to post messages to

params.client Object

Which client to use for network communication

Return:

Object

React component

public TypingIndicator(): Object source

A typing indicator component

Return:

Object

React component

public attempted(_: *): {type: CONNECTION_ATTEMPTED} source

Sets connection to attempted

Params:

NameTypeAttributeDescription
_ *

Return:

{type: CONNECTION_ATTEMPTED}

redux action type returned

public delayedMessageAdd(message: object): function() source

import {delayedMessageAdd} from 'react-web-chat/src/actions/messages.js'

Async action creator: Adds a new message after a delay of 1200 milliseconds. This is designed to simulate the "typing..." state of a chat user.

Params:

NameTypeAttributeDescription
message object

Return:

function()

dispatches messageAdd after 1200ms

TODO:

  • Make timeout duration a configurable setting.

public dropped(_: *): {type: CONNECTION_DROPPED} source

Sets connection to offline

Params:

NameTypeAttributeDescription
_ *

Return:

{type: CONNECTION_DROPPED}

redux action type returned

public established(_: *): {type: CONNECTION_ESTABLISHED} source

import {established} from 'react-web-chat/src/actions/connection.js'

Sets connection to established

Params:

NameTypeAttributeDescription
_ *

Return:

{type: CONNECTION_ESTABLISHED}

redux action type returned

public eventEmitterMiddleware(store: Object) source

import eventEmitterMiddleware from 'react-web-chat/src/middleware/eventEmitter.js'

Automatically dispatches custom events whenever a redux action is dispatched.

Params:

NameTypeAttributeDescription
store Object

a redux store instance

public getLatestRemote(messages: Array) source

import {getLatestRemote} from 'react-web-chat/src/utils/helpers.js'

Returns the latest remote message

Params:

NameTypeAttributeDescription
messages Array

public listening(_: *): {type: CONNECTION_LISTENING} source

Sets connection to listening

Params:

NameTypeAttributeDescription
_ *

Return:

{type: CONNECTION_LISTENING}

redux action type returned

public messageAdd(message: object): {type: MESSAGE_ADD} source

import {messageAdd} from 'react-web-chat/src/actions/messages.js'

Action creator: Adds a message to the store.

Params:

NameTypeAttributeDescription
message object

Return:

{type: MESSAGE_ADD}

redux action type returned

public messageReceive(message: object): function() source

import {messageReceive} from 'react-web-chat/src/actions/messages.js'

Async action creator: Dispatched when a message is received from the server. The message will get added to a dispatch queue.

Params:

NameTypeAttributeDescription
message object

Return:

function()

public messageSend(message: object): function() source

import {messageSend} from 'react-web-chat/src/actions/messages.js'

Async action creator: Dispatched when a message is received from the server. The message will get added to a dispatch queue.

Params:

NameTypeAttributeDescription
message object

Return:

function()

dispatches messageAdd action creator and MESSAGE_SEND action type

public remoteMessage(message: Object) source

import {remoteMessage} from 'react-web-chat/src/utils/filters.js'

Checks if a message belongs to remote

Params:

NameTypeAttributeDescription
message Object