otalk-chat-input-view

Otalk chat input view

otalk-chat-input-view

A chat input widget that can track typing states, and handle editing previous messages.

$ npm install otalk-chat-input-view
var ChatInputView = require('otalk-chat-input-view');
 
var client = SomeRealtimeConnection();
var peer = SomeContactModel();
 
var view = new ChatInputView({
    sendChatfunction (bodyprevID) {
        client.sendChat({
            to: peer.id,
            body: body,
            replace: prevID
        });
    },
    sendChatStatefunction (state) {
        client.sendChatState({
            to: peer.id,
            chatState: state
        });
    },
    previousMessagefunction () {
        return {
            id: peer.lastSentMessage.id,
            body: peer.lastSentMessage.body
        };
    }
});

MIT

If you like this, follow @lancestout on twitter.