Skip to content

Commit

Permalink
Notify profile changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Neakita committed Sep 22, 2023
1 parent d8401ab commit fe3fe30
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion SightKeeper.Application/Profile/Editing/ProfileEditor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reactive.Linq;
using System.Reactive.Subjects;
using FluentValidation;
using SightKeeper.Domain.Model;
using SightKeeper.Domain.Services;
Expand All @@ -7,7 +8,7 @@ namespace SightKeeper.Application;

public sealed class ProfileEditor
{
public IObservable<Profile> ProfileEdited { get; } = Observable.Empty<Profile>();
public IObservable<Profile> ProfileEdited => _profileEdited.AsObservable();

public ProfileEditor(IValidator<EditedProfileData> validator, ProfilesDataAccess profilesDataAccess)
{
Expand All @@ -28,8 +29,10 @@ public async Task ApplyChanges(EditedProfileDataDTO data)
foreach (var itemClass in data.ItemClasses)
profile.AddItemClass(itemClass);
await _profilesDataAccess.UpdateProfile(profile);
_profileEdited.OnNext(profile);
}

private readonly IValidator<EditedProfileData> _validator;
private readonly ProfilesDataAccess _profilesDataAccess;
private readonly Subject<Profile> _profileEdited = new();
}

0 comments on commit fe3fe30

Please sign in to comment.