Update INFO.yaml
[sdc/sdc-pubsub.git] / README.md
1 ## sdc-pubsub
2
3 sdc-pubsub [npm](https://www.npmjs.com/package/sdc-pubsub) package.
4
5 ### Installation
6
7 Installing using npm:
8
9 ```
10 npm install sdc-pubsub
11 ```
12
13 ### Loading It Up
14 #### CommonJS
15 ```javascript
16 import {PluginPubSub} from 'sdc-pubsub'
17 ```
18 #### Global Variable
19
20 ```html
21 <!-- index.html -->
22 <script src="./node_modules/sdc-pubsub/dist/sdc-pubsub.js"></script>
23 ```
24
25 ```javascript
26 // script.js
27 var pubsub = window.sdcPubSub.PluginPubSub;
28 ```
29
30 ### Usage
31 #### Initialize a pubsub client
32 ```javascript
33 // eventsClientId = client id to be used by the event bus, received from query params
34 // parentUrl = event bus location url for communication, received from query params
35 // eventsToWaitFor = list of events names that the event hub should wait for their completion.
36 //                   the client should send an "ACTION_COMPLETED" event to the hub in order to notify the event hub to continue with the flow.
37 //                   For example: [ “CHECK_IN” ]
38
39 var client = new PluginPubSub('eventsClientId, parentUrl, eventsToWaitFor')
40 ```
41
42 #### Notify about events
43 ```javascript
44 client.notify(“READY”)
45 ```
46
47 #### Register for an event
48 ```javascript
49 // When lisetning to event we have to specify the specific event we want to act once it being received.
50 // eventData.type will hold the event name that was notified by someone else
51 client.on((eventData,event) => {
52       if(eventData.type == ”WINDOW_OUT”) {
53           //do logic
54       }
55    }
56 )
57 ```
58
59 ### Dependencies
60
61 None.
62
63 ### Tests
64
65 None.
66
67 ### Authors
68
69 * Idan Amit: [https://wiki.onap.org/display/~idanamit](hhttps://wiki.onap.org/display/~idanamit)
70
71
72 ### Links
73
74 * SDC onap wiki [https://wiki.onap.org/x/_TX0](https://wiki.onap.org/x/_TX0)
75 * Generic designer support document [https://wiki.onap.org/display/DW/Generic+Designer+Support](https://wiki.onap.org/display/DW/Generic+Designer+Support)
76 * Repository [https://gerrit.onap.org/r/gitweb?p=sdc/sdc-pubsub.git;a=summary](https://gerrit.onap.org/r/gitweb?p=sdc/sdc-pubsub.git;a=summary)
77
78
79 ### License
80
81 Copyright 2018 AT&T, Inc.
82
83 Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0