Replies: 4 comments
-
Please, take a look to the following example: void Main()
{
var m1 = new Model(1);
var models = new[]
{
m1,
new Model(2),
new Model(3)
};
var changeSet = models.AsObservableChangeSet();
changeSet
.FilterOnObservable(x => x.IsActive)
.Bind(out var filteredCollection)
.Subscribe();
m1.Activate();
// Prints 1
filteredCollection.ToList().ForEach(x => Console.WriteLine(x.Id));
}
class Model
{
private BehaviorSubject<bool> isActive = new(false);
public Model(int id)
{
Id = id;
}
public int Id { get; }
public IObservable<bool> IsActive => isActive.AsObservable();
public override string ToString()
{
return Id.ToString();
}
internal void Activate()
{
isActive.OnNext(true);
}
} I think that you will understand how it works quickly. |
Beta Was this translation helpful? Give feedback.
-
As @SuperJMN showed in his example, the library requires a factory that returns public static IObservable<IChangeSet<TObject>> FilterOnObservable<TObject, TValue>(this IObservable<IChangeSet<TObject>> source,
Func<TObject, IObservable<TValue>> observableSelector,
Func<TValue, bool> predicate) =>
source.FilterOnObservable(obj => observableSelector(obj).Select(val => predicate(val))); |
Beta Was this translation helpful? Give feedback.
-
Where to find DynamicData.Samplz.Examples? |
Beta Was this translation helpful? Give feedback.
-
This is probably what you're looking for. |
Beta Was this translation helpful? Give feedback.
-
Hello, the operator is implemented in the new version (DynamicData 7.9.5) FilterOnObservable
But the example uses self-written
DynamicData.Samplz.Examples
Does the new method give the same result, how can I bring an example to a new look. Tell me, thanks.
I use [AvaloniaUI/Avalonia] and Entity Framework
convert to
public static IObservable<IChangeSet> FilterOnObservable(this IObservable<IChangeSet> source, Func<TObject, IObservable> objectFilterObservable, TimeSpan? propertyChangedThrottle = null, IScheduler? scheduler = null)
Beta Was this translation helpful? Give feedback.
All reactions