[API Reference](../README.md) > [EventService](../classes/EventService.md)



# Class: EventService

## Hierarchy

**EventService**

↳  [TransactionService](TransactionService.md)








## Index

### Methods

* [clearAllSubscriptions](EventService.md#clearAllSubscriptions)
* [publish](EventService.md#publish)
* [subscribe](EventService.md#subscribe)
* [unsubscribe](EventService.md#unsubscribe)



---
## Methods
<a id="clearAllSubscriptions"></a>

### «Static» clearAllSubscriptions

► **clearAllSubscriptions**(): `void`



*Defined in [eventService.ts:32](https://github.com/daostack/arc.js/blob/77005d4/lib/eventService.ts#L32)*



Remove all subscriptions




**Returns:** `void`





___

<a id="publish"></a>

### «Static» publish

► **publish**(topic: *`string`*, payload: *`any`*): `boolean`



*Defined in [eventService.ts:12](https://github.com/daostack/arc.js/blob/77005d4/lib/eventService.ts#L12)*



Send the given payload to subscribers of the given topic.


**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| topic | `string`   |  See [subscribe](EventService#subscribe) |
| payload | `any`   |  Sent in the subscription callback. |





**Returns:** `boolean`
True if there are any subscribers






___

<a id="subscribe"></a>

### «Static» subscribe

► **subscribe**(topics: *`string`⎮`Array`.<`string`>*, callback: *[EventSubscriptionCallback](../#EventSubscriptionCallback)*): [IEventSubscription](../interfaces/IEventSubscription.md)



*Defined in [eventService.ts:23](https://github.com/daostack/arc.js/blob/77005d4/lib/eventService.ts#L23)*



Subscribe to the given topic or array of topics.


**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| topics | `string`⎮`Array`.<`string`>   |  Identifies the event(s) to which you wish to subscribe |
| callback | [EventSubscriptionCallback](../#EventSubscriptionCallback)   |  The function to call when the requested events are published |





**Returns:** [IEventSubscription](../interfaces/IEventSubscription.md)
An interface with `.unsubscribe()`.  Be sure to call it!






___

<a id="unsubscribe"></a>

### «Static» unsubscribe

► **unsubscribe**(key: *[EventSubscriptionKey](../#EventSubscriptionKey)*): `void`



*Defined in [eventService.ts:44](https://github.com/daostack/arc.js/blob/77005d4/lib/eventService.ts#L44)*



Removes a subscription. When passed a token, removes a specific subscription, when passed a callback, removes all subscriptions for that callback, when passed a topic, removes all subscriptions for the topic hierarchy.


**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| key | [EventSubscriptionKey](../#EventSubscriptionKey)   |  A token, function or topic to unsubscribe. |





**Returns:** `void`





___


