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.
<aura:component implements="force:appHostable"> <forceChatter:feed type="groups"/> </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.
<aura:component implements="force:appHostable"> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <aura:attribute name="options" type="List" /> <aura:attribute name="type" type="String" default="News" description="The type of feed" access="GLOBAL"/> <aura:attribute name="types" type="String[]" default="Bookmarks,Company,DirectMessages,Feeds,Files,Filter,Groups,Home,Moderation,Mute,News,PendingReview,Record,Streams,To,Topics,UserProfile" description="A list of feed types"/> <h1>My Feeds</h1> <lightning:select aura:id="typeSelect" onchange="{!c.onChangeType}" label="Type" name="typeSelect"> <aura:iteration items="{!v.options}" var="item"> <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/> </aura:iteration> </lightning:select> <div aura:id="feedContainer"> <forceChatter:feed /> </div> </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.
({ // Handle component initialization doInit : function(component, event, helper) { var type = component.get("v.type"); var types = component.get("v.types"); var opts = new Array(); // Set the feed types on the lightning:select component for (var i = 0; i < types.length; i++) { opts.push({label: types[i], value: types[i], selected: types[i] === type}); } component.set("v.options", opts); }, onChangeType : function(component, event, helper) { var typeSelect = component.find("typeSelect"); var type = typeSelect.get("v.value"); component.set("v.type", type); // Dynamically create the feed with the specified type $A.createComponent("forceChatter:feed", {"type": type}, function(feed) { var feedContainer = component.find("feedContainer"); feedContainer.set("v.body", feed); }); } })
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.
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. |