ManagedMessageList
A managed list of messages for the specified conversation.
Constructor Summary
Public Constructor | ||
public |
constructor(conversation: Conversation, options: object) |
Member Summary
Public Members | ||
public get |
List length (like the array length property) |
Method Summary
Public Methods | ||
public |
add(message: Message): ManagedMessageList Add a message, no-op if the message already exists. |
|
public |
destroy() If you used pubsubSync, you must call this function when the list is no longer needed to prevent a memory leak. |
|
public |
fetch(resultLimit: number): Promise<ManagedMessageList> Fetches list of conversations from the server. |
|
public |
List filter method (like the array filter method) |
|
public |
Get a Message |
|
public |
List mapping method (like the array map method) |
|
public |
remove(messageID: string): ManagedMessageList Remove a message, no-op if the message doesn't exist. |
|
public |
Subscribe to list updates, handler will be called with one argument: this object. |
|
public |
unsubscribe(subID: number) Cancel a subscription. |
|
public |
update(message: Message): ManagedMessageList Update a message, no-op if the message updatedAt date is older than existing. |
Public Constructors
public constructor(conversation: Conversation, options: object) source
Params:
Name | Type | Attribute | Description |
conversation | Conversation | ||
options | object |
|
|
options.initialFetch | number | boolean |
|
Fetch messages on creation, provide limit of messages to fetch or false to disable. |
options.pubsubSync | boolean |
|
Keep list synchronized with server using PubSub. |
options.autoRead | boolean |
|
Automatically mark all recieved messages as read. |
Public Methods
public add(message: Message): ManagedMessageList source
Add a message, no-op if the message already exists. Will mark the message as read if the autoRead option is true.
Params:
Name | Type | Attribute | Description |
message | Message |
public destroy() source
If you used pubsubSync, you must call this function when the list is no longer needed to prevent a memory leak.
public fetch(resultLimit: number): Promise<ManagedMessageList> source
Fetches list of conversations from the server.
Params:
Name | Type | Attribute | Description |
resultLimit | number |
|
Limit of the number of messages to fetch. |
public filter(predicate: function): Array source
List filter method (like the array filter method)
Params:
Name | Type | Attribute | Description |
predicate | function |
public map(mappingFunction: function): Array source
List mapping method (like the array map method)
Params:
Name | Type | Attribute | Description |
mappingFunction | function |
public remove(messageID: string): ManagedMessageList source
Remove a message, no-op if the message doesn't exist.
Params:
Name | Type | Attribute | Description |
messageID | string | Message ID without type prefix. |
public subscribe(handler: function): number source
Subscribe to list updates, handler will be called with one argument: this object.
Params:
Name | Type | Attribute | Description |
handler | function |
public unsubscribe(subID: number) source
Cancel a subscription.
Params:
Name | Type | Attribute | Description |
subID | number | The subscription ID returned by the subscribe function. |
public update(message: Message): ManagedMessageList source
Update a message, no-op if the message updatedAt date is older than existing. Message will be added if it's not in the list.
Params:
Name | Type | Attribute | Description |
message | Message |