- Remove static method
noConflict()
.
- Add a new static method
createInstance()
as alternative way to create a newPubSub
instance. - Export library in UMD, ESM and CommonJS formats.
- Refactor source code to ES2015+.
- Use rollup.js to bundle the library.
- Replace Mocha with Jest as testing framework.
- Improve tests and coverage.
- Replace Travis with Github Actions for CI.
- Update
devDependencies
- Update CI configuration
- Delete examples folder
- Fix issue #4
- Add
immediateExceptions
option when creating instance
- Update
devDependencies
- Use
mocha
andchai
for testing instead ofkarma
andjasmine
- Drop support Bower support
- Exclude
dist
folder from source control
- Add static method
PubSub.noConflict()
to roll back the globalPubSub
identifier. Used in a normal browser global namespace environment to avoid conflicts, etc.
- If there is no subscriber for a topic, delete topic property when unsubscribing. Used to leave it as an empty array before.
- The result of
subscribers
andsubscribersByTopic
methods is just a copy of the original object or array accordingly. - Keep devDependencies up to date.
Allow passing multiple data arguments to publish
and publishSync
methods.
var pubsub = new PubSub();
pubsub.subscribe('event', function (data) {
console.log(data);
// => Array [{fname: 'John'}, {lname: 'Doe'}, [1, 2, 3], 'Lorem ipsum dolor sit amet.']
console.log(data[0]);
// => Object {lname: 'John'}
console.log(data[1]);
// => Object {lname: 'Doe'}
console.log(data[2]);
// => Array [1, 2, 3]
console.log(data[3]);
// => String "Lorem ipsum dolor sit amet."
});
pubsub.publish('event', {fname: 'John'}, {lname: 'Doe'}, [1, 2, 3], 'Lorem ipsum dolor sit amet.');
- Ensure that listeners registered on the same topic are invoked in the order they are added.
- Minor updates on documentation.
- Update angular_1.x_example.
- Add working example using Angular 1.x.
- Update devDependencies.
- Improve tests and coverage
- Return a new instance of
PubSub
if it is invoked without thenew
keyword. - Add code coverage.
- Keep devDependencies up to date
- Fix License
- Add public method
subscribersByTopic()
to get an array of subscribers for a specific topic.
hasSubscribers
checks if there is at least one subscriber, no matter its name, if no argument is passed.- Add public method
subscribers()
to get a readonly object of the current subscribers.
The default API method aliases are deprecated and removed from v3.0.0 onwards. However there is a new method alias
introduced, that allows to create your own aliases. Therefore, if you already use those aliases in a project you can use the alias
method to provide your own.
Below is a map of the default aliases that existed prior to version 3.0.0:
Original method | Alias method |
---|---|
subscribe |
on |
subscribeOnce |
once |
publishSync |
triggerSync |
unsubscribe |
off |
hasSubscribers |
has |
To create your own aliases:
var pubsub = new PubSub().alias({
subscribe: 'on',
subscribeOnce: 'once',
publish: 'trigger',
publishSync: 'triggerSync',
unsubscribe: 'off',
hasSubscribers: 'has'
});
- Add public method
unsubscribeAll
to clear all subscriptions whatsoever. - Add public method
alias
to create your own method aliases. (See above) - Provide source-map for the minified library.
- Add support for publishing events synchronously using
publishSync
method. - Add public method
hasSubscribers
to check if there are subscribers for a specific topic.
- Add support for Travis CI.
- Lint source code using ESLint.
- Keep devDependencies up to date.
- Reverse the arguments the
callback
function accepts, in order to allow the usage ofdata
argument without the need to also specify thetopic
if not needed. - Throw exception if
callback
is not afunction
or is not provided at all.
- Return token on
subscribeOnce
method. - Correct annotations and provide examples.
- Update devDependencies.
- Provide
npm
scripts to run the tasks. No more need for global dependencies installed (Grunt).