Panic Client
Lightweight client for panic-server
Docs
Since this library is just support for panic-server, you can find the majority of the documentation over there.
Installing
Panic-client is hosted on npm, and can be installed by running this in your terminal:
npm install panic-client
If you're not familiar with npm, you can learn more by clicking here, or you can install it by following these instructions.
Usage
Panic-client's API surface area is pretty small, since it's just a small wrapper around socket.io. It consists of one method, server
, and two properties, connection
and platform
.
There are two ways to include it in your code, depending on your environment...
Node.js
var panic = require('panic-client')
Browser
If you're using panic-server, the server automatically delivers the browser file at the at the port/hostname you configured. By default, it will be 'http://localhost:8080/panic.js'.
If you're not using panic-server, it may be more complicated, depending on your file structure. If you're using webpack, simply include it the same way as you would on Node.js. Otherwise, the browser build is located at root level, named panic.js
. Simply point a script tag there, or copy it into your project root...
<script src="node_modules/{path to panic-client}/panic.js"></script>
<script>
panic;
</script>
Best practice is to load through panic-server.
<script src="http://localhost:8080/panic.js"></script>
.server(String)
This method attempts to connect to your panic-server host, and allows panic-server to run code on your machine in real-time. Just give it the url.
panic.server('http://localhost:8080')
.connection
panic.connection
is the websocket opened to panic-server. If you haven't called panic.server()
yet, it'll be null
.
.platform
The panic.platform
object is created by platform.js, and contains information about what environment the code is running on.
Support
If you have questions or ideas, please let us know on our gitter channel :grinning: