timonkrebs / MemoizR

Declarative Structured Concurrency for C#
Apache License 2.0
106 stars 3 forks source link

Support new `Set(Func<T, T> update)` overload #34

Closed linkdotnet closed 6 months ago

linkdotnet commented 6 months ago

There are cases where you are not interested in the absolut value of a signal, but you want to calculate on the current value.

Given a simple +1 counter or pagination where you are just interested in increasing the value.

API Proposal

public sealed class Signal<T> : MemoHandlR<T>
{
+    public async Task Set(Func<T, T> updateFunc);
}

Alternatively a new Update method could be helpful:

public sealed class Signal<T> : MemoHandlR<T>
{
+    public async Task Update(Func<T, T> updateFunc);
}
timonkrebs commented 6 months ago

This already exists: MemoizR/EagerRelativeSignal.cs

linkdotnet commented 6 months ago

Fair enough :)