import ManagedConversationList from 'js-chat-demo/utils/ManagedConversationList.jsx'
ManagedConversationList
A managed list of conversations for the current user. Note: You must be logged in to use this.
Constructor Summary
Public Constructor | ||
public |
constructor(options: object) |
Member Summary
Public Members | ||
public get |
List length (like the array length property) |
Method Summary
Public Methods | ||
public |
add(conversation: Conversation): ManagedConversationList Add a conversation, no-op if the conversation 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 |
Fetches list of conversations from the server. |
|
public |
List filter method (like the array filter method) |
|
public |
Get a Conversation |
|
public |
List mapping method (like the array map method) |
|
public |
remove(conversationID: string): ManagedConversationList Remove a conversation, no-op if the conversation 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(conversation: Conversation): ManagedConversationList Update a conversation, no-op if the conversation updatedAt date is older than existing. |
Public Constructors
public constructor(options: object) source
Params:
Name | Type | Attribute | Description |
options | object |
|
|
options.initialFetch | boolean |
|
Automatically fetch list of conversations on creation. |
options.pubsubSync | boolean |
|
Keep list synchronized with server using PubSub. |
options.sortBy | function |
|
How the list is sorted, you can use ConversationSorting wrapper to create one or provide your own. |
Public Methods
public add(conversation: Conversation): ManagedConversationList source
Add a conversation, no-op if the conversation already exists.
Params:
Name | Type | Attribute | Description |
conversation | Conversation |
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(): Promise<ManagedConversationList> source
Fetches list of conversations from the server.
Return:
Promise<ManagedConversationList> | Promise of this object, resolves if the fetch is successful. |
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(conversationID: string): ManagedConversationList source
Remove a conversation, no-op if the conversation doesn't exist.
Params:
Name | Type | Attribute | Description |
conversationID | string | Conversation 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(conversation: Conversation): ManagedConversationList source
Update a conversation, no-op if the conversation updatedAt date is older than existing. Conversation will be added if it's not in the list.
Params:
Name | Type | Attribute | Description |
conversation | Conversation |