This commit is contained in:
2021-10-09 14:16:03 +03:00
parent 2e1726af75
commit 502d679848
5 changed files with 11 additions and 6 deletions

View File

@@ -27,5 +27,7 @@ namespace DTLib.Reactive
Streams.Remove(stream);
stream.ElementAdded-=ElementAdded;
});
//public T GetElement()
}
}

View File

@@ -1,10 +1,11 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace DTLib.Reactive
{
public class ReactiveStream<T>
{
List<T> Storage = new();
List<(long time, T value)> Storage = new();
public event EventHandlerAsync<T> ElementAdded;
SafeMutex StorageMutex = new();
public int Length => StorageMutex.Execute(() => Storage.Count);
@@ -13,7 +14,7 @@ namespace DTLib.Reactive
public void Add(T elem)
{
StorageMutex.Execute(() => Storage.Add(elem));
StorageMutex.Execute(() => Storage.Add((DateTime.Now.Ticks, elem)));
ElementAdded?.Invoke(this, elem);
}