From b8cc23940870cd2a78f629624fc8256a373f12d5 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 8 Jun 2014 12:21:24 -0700 Subject: [PATCH] Document getMessages and getLastMessage --- reference.html | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/reference.html b/reference.html index 18d07d6..f7f50e2 100644 --- a/reference.html +++ b/reference.html @@ -509,6 +509,41 @@ current profile.

back from the server. You can filter messages by comparing their sender field to the return value of currentProfile() to avoid processing your own messages.

+ +

getMessages()

+ +

Arguments: +

    +
  1. subject: A valid subject (string, number or object with + specific keys)
  2. +

+ +

Returns: An ordered (oldest to newest) array of message objects.

+ +

The client library keeps a cache of messages received from +subscriptions. getMessage() returns the contents of that cache.

+ +

Note that only subjects for which subscribe() has been called are valid +to pass to getMessage(), and that getMessage() only returns historical messages as specified by the +arguments to subscribe(). To fetch more historical messages, call subscribe() again with different +arguments.

+ + +

getLastMessage()

+ +

Arguments: +

    +
  1. subject: A valid subject (string, number or object with + specific keys)
  2. +

+ +

Returns: The most recent message object received, or null if none.

+ +

Similar to getMessages(), but only returns the most recent message +received from the server (in server sequence number ordering). This is useful for applications +using Cosmopolite as a key/value store that don't need to interact with the historical messages. +

+