Newer Version Available
forceChatter:feed
A forceChatter:feed component represents a feed that's specified by its type. Use the type attribute to display a specific feed type. For example, set type="groups" to display the feed from all groups the context user either owns or is a member of.
1<aura:component implements="force:appHostable">
2 <forceChatter:feed type="groups"/>
3</aura:component>You can also display a feed depending on the type selected. This example provides a drop-down menu that controls the type of feed to display.
1<aura:component implements="force:appHostable">
2 <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
3 <aura:attribute name="options" type="List" />
4 <aura:attribute name="type" type="String" default="News" description="The type of feed" access="GLOBAL"/>
5 <aura:attribute name="types" type="String[]"
6 default="Bookmarks,Company,DirectMessages,Feeds,Files,Filter,Groups,Home,Moderation,Mute,News,PendingReview,Record,Streams,To,Topics,UserProfile"
7 description="A list of feed types"/>
8 <h1>My Feeds</h1>
9<lightning:select aura:id="typeSelect" onchange="{!c.onChangeType}" label="Type" name="typeSelect">
10 <aura:iteration items="{!v.options}" var="item">
11 <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
12 </aura:iteration>
13 </lightning:select>
14 <div aura:id="feedContainer" class="feed-container">
15 <forceChatter:feed />
16 </div>
17</aura:component>The types attribute specifies the feed types, which are set on the lightning:select component during component initialization. When a user selects a feed type, the feed is dynamically created and displayed.
1({
2 // Handle component initialization
3 doInit : function(component, event, helper) {
4 var type = component.get("v.type");
5 var types = component.get("v.types");
6 var opts = new Array();
7
8 // Set the feed types on the lightning:select component
9 for (var i = 0; i < types.length; i++) {
10 opts.push({label: types[i], value: types[i], selected: types[i] === type});
11 }
12 component.set("v.options", opts);
13 },
14
15 onChangeType : function(component, event, helper) {
16 var typeSelect = component.find("typeSelect");
17 var type = typeSelect.get("v.value");
18 component.set("v.type", type);
19
20 // Dynamically create the feed with the specified type
21 $A.createComponent("forceChatter:feed", {"type": type}, function(feed) {
22 var feedContainer = component.find("feedContainer");
23 feedContainer.set("v.body", feed);
24 });
25 }
26})The feed component is supported for Lightning Experience and communities based on the Customer Service template.
For a list of feed types, see the Chatter REST API Developer's Guide.
Attributes
| Attribute Name | Attribute Type | Description | Required? |
|---|---|---|---|
| body | Component[] | The body of the component. In markup, this is everything in the body of the tag. | |
| feedDesign | String | Valid values include DEFAULT ( shows inline comments on desktop, a bit more detail ) or BROWSE ( primarily an overview of the feed items ) | |
| subjectId | String | For most feeds tied to an entity, this is used specified the desired entity. Defaults to the current user if not specified | |
| type | String | The strategy used to find items associated with the subject. Valid values include: Bookmarks, Company, DirectMessages, Feeds, Files, Filter, Groups, Home, Moderation, Mute, News, PendingReview, Record, Streams, To, Topics, UserProfile. |