initial load
This commit is contained in:
43
YouTubeViewers.WPF/Stores/SelectedYouTubeViewerStore.cs
Normal file
43
YouTubeViewers.WPF/Stores/SelectedYouTubeViewerStore.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YouTubeViewers.Domain.Models;
|
||||
|
||||
namespace YouTubeViewers.WPF.Stores
|
||||
{
|
||||
public class SelectedYouTubeViewerStore
|
||||
{
|
||||
private readonly YouTubeViewersStore _youTubeViewersStore;
|
||||
|
||||
public SelectedYouTubeViewerStore(YouTubeViewersStore youTubeViewersStore)
|
||||
{
|
||||
_youTubeViewersStore = youTubeViewersStore;
|
||||
_youTubeViewersStore.YouTubeViewerUpdated += YouTubeViewersStore_YouTubeViewerUpdated;
|
||||
}
|
||||
|
||||
private void YouTubeViewersStore_YouTubeViewerUpdated(YouTubeViewer youTubeViewer)
|
||||
{
|
||||
if (youTubeViewer.Id == SelectedYouTubeViewer?.Id)
|
||||
{
|
||||
SelectedYouTubeViewer = youTubeViewer;
|
||||
}
|
||||
}
|
||||
|
||||
private YouTubeViewer _selectedYouTubeViewer;
|
||||
|
||||
public YouTubeViewer SelectedYouTubeViewer
|
||||
{
|
||||
get { return _selectedYouTubeViewer; }
|
||||
set
|
||||
{
|
||||
_selectedYouTubeViewer = value;
|
||||
SelectedYouTubeViewerChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public event Action SelectedYouTubeViewerChanged;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user