Skip to content

Instantly share code, notes, and snippets.

@jasongaylord
Created November 6, 2018 02:54
Show Gist options
  • Save jasongaylord/1dde496f0df23ffc3f06664c0914a40d to your computer and use it in GitHub Desktop.
Save jasongaylord/1dde496f0df23ffc3f06664c0914a40d to your computer and use it in GitHub Desktop.
public class RetrieveTweetsViewComponent : ViewComponent
{
protected TwitterOptions TwitterOptions { get; private set; }
public RetrieveTweetsViewComponent(IOptions<TwitterOptions> options = null)
{
if (options != null)
TwitterOptions = options.Value;
else
TwitterOptions = new TwitterOptions();
}
public async Task<IViewComponentResult> InvokeAsync()
{
var service = new TwitterService();
var tweets = await service.RetrieveTweetsAsync(TwitterOptions);
return View("Default", tweets);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment