Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including otalk-chat-input-view with all npm packages installed. Try it out:

var otalkChatInputView = require("otalk-chat-input-view")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

otalk-chat-input-view v2.0.0

Otalk chat input view

otalk-chat-input-view

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

Installing

$ npm install otalk-chat-input-view

Using

var ChatInputView = require('otalk-chat-input-view');

var client = SomeRealtimeConnection();
var peer = SomeContactModel();

var view = new ChatInputView({
    sendChat: function (body, prevID) {
        client.sendChat({
            to: peer.id,
            body: body,
            replace: prevID
        });
    },
    sendChatState: function (state) {
        client.sendChatState({
            to: peer.id,
            chatState: state
        });
    },
    previousMessage: function () {
        return {
            id: peer.lastSentMessage.id,
            body: peer.lastSentMessage.body
        };
    }
});

License

MIT

Created By

If you like this, follow @lancestout on twitter.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free