-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major changes and simplification
- Loading branch information
Bernhard Straub
committed
Mar 17, 2024
1 parent
5716749
commit 6ee6a3f
Showing
70 changed files
with
2,181 additions
and
2,298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
RxBlazorLightCore/Component/RxBLServiceStateSubscriberS.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,64 @@ | ||
| ||
using System; | ||
using System.Reactive; | ||
using System.Reactive.Linq; | ||
using System.Reactive.Subjects; | ||
|
||
namespace RxBlazorLightCore | ||
{ | ||
public static class RxExtensions | ||
{ | ||
public static IState<TInterface, TType> CreateState<S, TInterface, TType>(this S service, TType? value, Func<IState<TInterface, TType>, IStateTransformer<TType>>? stateProviderTransformerFactory = null) | ||
where S : RxBLService | ||
where TType : class, TInterface | ||
{ | ||
return State<S, TInterface, TType>.Create(service, value, stateProviderTransformerFactory); | ||
} | ||
|
||
public static IState<TType> CreateState<S, TType>(this S service, TType? value, Func<IState<TType>, IStateTransformer<TType>>? stateProviderTransformerFactory = null) where S : RxBLService | ||
{ | ||
return State<S, TType>.Create(service, value, stateProviderTransformerFactory); | ||
} | ||
|
||
public static IObservableStateProvider CreateObservableStateProvider<S>(this S service) where S : RxBLService | ||
public static IState CreateState(this RxBLService service) | ||
{ | ||
return ObservableStateProvider<S>.Create(service); | ||
return State.Create(service); | ||
} | ||
|
||
public static IObservableStateProvider<T> CreateObservableStateProvider<S, T>(this S service, IState<T> state) where S : RxBLService | ||
public static IStateAsync CreateStateAsync(this RxBLService service) | ||
{ | ||
return ObservableStateProvider<S, T>.Create(service, state); | ||
return StateAsync.Create(service); | ||
} | ||
|
||
public static IObservable<Unit> GetStatePhaseObservable<S>(this S service, IStateProvideTransformBase stateProviderTransformer, | ||
StateChangePhase phase = StateChangePhase.CHANGED) where S : RxBLService | ||
public static IState<T> CreateState<T>(this RxBLService service, T value) | ||
{ | ||
return service | ||
.Where(sc => sc.ID == stateProviderTransformer.ID && stateProviderTransformer.Phase == phase) | ||
.Select(_ => Unit.Default); | ||
return State<T>.Create(service, value); | ||
} | ||
|
||
public static bool Changing(this IStateProvideTransformBase stateProviderTransformer) | ||
public static IStateAsync<T> CreateStateAsync<T>(this RxBLService service, T value) | ||
{ | ||
return stateProviderTransformer.Phase is StateChangePhase.CHANGING; | ||
return StateAsync<T>.Create(service, value); | ||
} | ||
|
||
public static bool Changed(this IStateProvideTransformBase stateProviderTransformer) | ||
public static IStateGroup<T> CreateStateGroup<T>(this RxBLService service, T[] items, T inititalItem, Func<int, bool>? itemDisabledDelegate = null) | ||
{ | ||
return stateProviderTransformer.Phase is StateChangePhase.CHANGED; | ||
return StateGroup<T>.Create(service, items, inititalItem, itemDisabledDelegate); | ||
} | ||
|
||
public static bool Completed(this IStateProvideTransformBase stateProviderTransformer) | ||
public static IStateGroupAsync<T> CreateStateGroupAsync<T>(this RxBLService service, T[] items, T inititalItem, Func<int, bool>? itemDisabledDelegate = null) | ||
{ | ||
return stateProviderTransformer.Phase is StateChangePhase.COMPLETED; | ||
return StateGroupAsync<T>.Create(service, items, inititalItem, itemDisabledDelegate); | ||
} | ||
|
||
public static bool Canceled(this IStateProvideTransformBase stateProviderTransformer) | ||
public static bool Changing<T>(this IStateBase<T> state) | ||
{ | ||
return stateProviderTransformer.Phase is StateChangePhase.CANCELED; | ||
return state.Phase is StatePhase.CHANGING; | ||
} | ||
|
||
public static bool Exception(this IStateProvideTransformBase stateProviderTransformer) | ||
public static bool Changed<T>(this IStateBase<T> state) | ||
{ | ||
return stateProviderTransformer.Phase is StateChangePhase.EXCEPTION; | ||
return state.Phase is StatePhase.CHANGED; | ||
} | ||
|
||
public static bool Done(this IStateProvideTransformBase stateProviderTransformer) | ||
public static bool Canceled<T>(this IStateBase<T> state) | ||
{ | ||
return stateProviderTransformer.Phase is StateChangePhase.CHANGED || | ||
stateProviderTransformer.Phase is StateChangePhase.CANCELED || | ||
stateProviderTransformer.Phase is StateChangePhase.EXCEPTION; | ||
return state.Phase is StatePhase.CANCELED; | ||
} | ||
|
||
internal static void RunValueTask(this ValueTask valueTask) | ||
public static bool Exception<T>(this IStateBase<T> state) | ||
{ | ||
if (!valueTask.IsCompleted) | ||
{ | ||
throw new InvalidOperationException("ValueTask does not run synchronously!"); | ||
} | ||
|
||
valueTask.GetAwaiter().GetResult(); | ||
return state.Phase is StatePhase.EXCEPTION; | ||
} | ||
|
||
internal static TResult RunValueTask<TResult>(this ValueTask<TResult> valueTask) | ||
public static bool Done<T>(this IStateBase<T> state) | ||
{ | ||
if (!valueTask.IsCompleted) | ||
{ | ||
throw new InvalidOperationException("ValueTask does not run synchronously!"); | ||
} | ||
|
||
return valueTask.GetAwaiter().GetResult(); | ||
return state.Phase is StatePhase.CHANGED || | ||
state.Phase is StatePhase.CANCELED || | ||
state.Phase is StatePhase.EXCEPTION; | ||
} | ||
} | ||
} |
Oops, something went wrong.