encore-publish-subscribe-service
v1.0.1
Published
Publisher/Subscriber class that allows us connect applications or modules inside application
Downloads
26
Maintainers
Keywords
Readme
Encore Pub/Sub Service
Publisher/Subscriber class that allows us connect applications or modules inside application
Install
$ npm install encore-publish-subscribe-service
Usage
- Import Pub/Sub class
- Create an instance, using application name
- Use Encore Pub/Sub instance
Documentation
Library is working with special event format: {widget name}_{view name}_{event name} View name could be empty. Widget and event names should use dash as a word separator.
Service provide two groups of connection methods and one helper method for event name generation:
Publish methods
emit - call event on specific HTML element globalEmit - call event on window
Subscribe methods
subscribe - listen to event on specific HTML element, return unsubscribe function globalSubscribe - listen to event on window
Helper method
getEventName - return formatted event name