Git Product home page Git Product logo

chitchat's Introduction

ChitChat

ChitChat is a lighweight simple JavaScript library that uses the HTML5 postMessage feature to communicate messages across iframes in a single window.

###ChitChat library goals:###

  1. lightweight
  2. consumers can self-register with provider
  3. consumers can subscribe to a single broadcast type
  4. At the consumer, the message listening function passes the message to a local function. Aptly called, localFunc.

Download the minified library and include it in your html.

You'll need to initiate the provider in the parent frame.

Examples โ€” Documentation

##Provider Init##

<script src="js/chitchat.js"></script>

<script defer>
    var provider = new ChitChat.Provider();
</script>

Once the provider is initialized, consumers register a subscription type. When a consumer posts a message, it will be passed along to all consumers with the target subscription.

##Consumer Init##

<script src="js/chitchat.js"></script>

<script defer>
   // subscribing to 'book' messages
    var consumer = new ChitChat.Consumer('book');
</script>

Communication in ChitChat is defined by packets. Packets provide a basic structure for routing and registration. Here is an example of

##ChitChat Packet Init##

<script>
    var pkt = new ChitChat.Packet({message: msg, target: this.sub });
</script>

Place your JS Object onto the message parameter or extend the Packet with your own parameters.

##ChitChat Packet##

<script>
ChitChat.Packet = function (params) {
    this.who = params ? params.who : undefined;

    // types:  reg || framework
    this.type = params ? params.type : undefined;

    // payload
    this.message = params ? params.message : undefined;

    // the targeted subscription type
    this.target = params ? params.target : 'default';

    // Add additional parameters below
};
</script>

chitchat's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

imclab

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.