Add getLastMessage() for easier key/value storing.

This commit is contained in:
Ian Gulliver
2014-05-26 10:02:37 -07:00
parent 898121dabd
commit 070521493b
2 changed files with 17 additions and 1 deletions

View File

@@ -228,6 +228,21 @@ Cosmopolite.prototype.getMessages = function(subject) {
return this.subscriptions_[subjectString].messages;
};
/**
* Fetch the most recent message for a subject
*
* @param {!string} subject Subject name
* @const
*/
Cosmopolite.prototype.getLastMessage = function(subject) {
var messages = this.getMessages(subject);
if (messages.length) {
return messages[messages.length - 1];
} else {
return null;
}
};
/**
* Fetch all current pins for a subject
*