Skip to content

A Polymer element to ease the use and configuration of WebSockets

Notifications You must be signed in to change notification settings

simonmallet/web-socket

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

web-socket Build Status

A Polymer element to ease the use and configuration of WebSockets.

<web-socket url="ws://echo.websocket.org"
            auto json
            on-open="_onOpen"
            on-close="_onClose"
            on-message="_onMessage"
            on-error="_onError">
</web-socket>

The above example shows how to establish a WebSocket connection with <web-socket> in a Polymer app. This simple declarative element definition is:

  • Establishing a connection to ws://echo.websocket.org.
  • Automatically connecting on page load and reconnecting on url change.
  • Parsing and stringifying JSON automatically.
  • Automatically reconnecting in the event of an unclean close event (a default behaviour of this library - no configuration required through properties).
  • Setting up event handlers to functions declared externally (_onOpen, _onClose, etc - defined by a parent element, such as a page).

Install

You can install <web-socket> with Bower

bower install web-socket

You can also view the documentation, try the demo and run the tests.

About

A Polymer element to ease the use and configuration of WebSockets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 100.0%