Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seikho/events-client
Browser client for ls-events
https://github.com/seikho/events-client
Last synced: 5 days ago
JSON representation
Browser client for ls-events
- Host: GitHub
- URL: https://github.com/seikho/events-client
- Owner: Seikho
- Created: 2015-10-11T13:34:46.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-11T13:40:33.000Z (about 9 years ago)
- Last Synced: 2024-08-31T02:52:02.524Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 102 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### Longshot: events-client
Client-side events subscription using Socket.io#### Installation
`npm install ls-events-client --save`
or
`jspm install npm:ls-events-client`#### Usage
The `events-client` API is fluent. See below:
```javascript
// ES6
import events = require("ls-events-client");//
events
.setHost("localhost", 10001);
.start()
.sub("users", "create", "*", msg => {
// Subscribe to all user created events
})
.sub("users", "update", "carl", msg => {
// Subscribe to all updates to the user 'carl'
});
```#### API
##### setHost
Set the host end-point details
```javascript
function setHost(host: string, port: number): Client;```
##### start
Connect to the end point
```javascript
function start(): Client;
```
##### subscribe
**N.B.:** `context`, `event`, and `key` can be null or "\*". These both refer to 'all'.* `Context`: The type of object. E.g. `users`, `invoices`, `orders`, `items`, etc.
* `Event`: The type of event raised. E.g. `create`, `read`, `update`, `delete`, `notify`, etc.
* `Key`: The key of the object.```javascript
function sub(context?: string, event?: string, key?: string): Client;
```