1 | # Appcelerator PubSub Client library [![Build Status](https://travis-ci.org/appcelerator/appc-pubsub.svg?branch=master)](https://travis-ci.org/appcelerator/appc-pubsub)
|
2 |
|
3 | The library makes it easy to publish events to the Appcelerator PubSub API service.
|
4 |
|
5 | ## Installation
|
6 |
|
7 | npm install appc-pubsub --save
|
8 |
|
9 | ## Usage
|
10 |
|
11 | You must first include the library and create an instance. At a minimum, you must pass in the `key` and `secret` values for constructing the client.
|
12 |
|
13 | ```javascript
|
14 | var PubSub = require('appc-pubsub'),
|
15 | pubsub = new PubSub({
|
16 | key: 'MY_KEY',
|
17 | secret: 'MY_SECRET'
|
18 | });
|
19 | ```
|
20 |
|
21 | Once you have created the client instance, you can publish events.
|
22 |
|
23 | ```javascript
|
24 | pubsub.publish('com.foo.bar');
|
25 | ```
|
26 |
|
27 | You can optional pass payload data for your event by passing an object as the second parameter:
|
28 |
|
29 | ```javascript
|
30 | pubsub.publish('com.foo.bar', {bar:1});
|
31 | ```
|
32 |
|
33 | ## License
|
34 |
|
35 | The library is Confidential and Proprietary to Appcelerator, Inc. and licensed under the Appcelerator Software License Agreement. Copyright (c) 2015 by Appcelerator, Inc. All Rights Reserved.
|