Skip to content

Commit

Permalink
BREAKING Make JS client throw if lastId not number
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolai-b authored and SamSaffron committed Jul 30, 2020
1 parent fe340ad commit e309b6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG
@@ -1,3 +1,7 @@
- Unreleased

- BREAKING CHANGE: In the JavaScript client throw when when lastId is given but is not a number.

09-06-2020

- Version 3.3.1
Expand Down
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -304,6 +304,11 @@ MessageBus.subscribe("/channel", function(data){
MessageBus.subscribe("/channel", function(data){
// data shipped from server
}, -3);

// you will get the entire backlog
MessageBus.subscribe("/channel", function(data){
// data shipped from server
}, 0);
```

#### JavaScript Client settings
Expand Down
5 changes: 4 additions & 1 deletion assets/message-bus.js
Expand Up @@ -484,13 +484,16 @@
// -1 will subscribe to all new messages
// -2 will recieve last message + all new messages
// -3 will recieve last 2 messages + all new messages
// if undefined will default to -1
subscribe: function(channel, func, lastId) {
if (!started && !stopped) {
me.start();
}

if (typeof lastId !== "number") {
if (lastId === null || typeof lastId === "undefined") {
lastId = -1;
} else if (typeof lastId !== "number") {
throw "lastId has type " + typeof lastId + " but a number was expected.";
}

if (typeof channel !== "string") {
Expand Down

0 comments on commit e309b6d

Please sign in to comment.