You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an interface that event classes can inherit from.
// A better name may be something like IRx or IReactive?
public interface IEvent<T>
{
T Data { get; }
}
the implementation could then look like the following
public class RxUIControlEvents : IEvent<UIControl>
{
public UIControl Data => _data;
private readonly global::UIKit.UIControl _data;
/// <summary>
/// Initializes a new instance of the <see cref = "global::UIKit.UIControl"/> class.
/// </summary>
/// <param name = "data">The class that is being wrapped.</param>
public RxUIControlEvents(global::UIKit.UIControl data)
{
_data = data;
}
// Event bindings removed for brevity
}
Why would this be useful?
This would then make it easy to create static helper methods for updating UI elements based on observables
from the view code (e.g. UIViewController in iOS) this would enable
button = new UIButton();
ViewModel.Command
.CanExecute
.Subscribe(button.Events().Enabled())
.DisposeWith(disp);
Additional Considerations
I'm coming from an iOS/Android perspective, so understand that the interface might not apply to all situations; pharmacist is about creating observables from events, so the IEvents idea might be a level on top of pharmacist?
RxSwift uses Rx where Pharmacist uses Events by default; adding the base interface would mean that Pharmacist wouldn't just be for events
Using the example above
ViewModel.Command
.CanExecute
// Confusing as this isn't an event
.Subscribe(button.Events().Enabled())
.DisposeWith(disp);
the Rx naming now makes more sense?
ViewModel.Command
.CanExecute
// More like the RxSwift style
.Subscribe(button.Rx().Enabled())
.DisposeWith(disp);
The text was updated successfully, but these errors were encountered:
Describe the solution you'd like
Add an interface that event classes can inherit from.
the implementation could then look like the following
Why would this be useful?
This would then make it easy to create static helper methods for updating UI elements based on observables
from the view code (e.g.
UIViewController
in iOS) this would enableAdditional Considerations
I'm coming from an iOS/Android perspective, so understand that the interface might not apply to all situations; pharmacist is about creating observables from events, so the
IEvents
idea might be a level on top of pharmacist?RxSwift uses
Rx
where Pharmacist usesEvents
by default; adding the base interface would mean that Pharmacist wouldn't just be for eventsUsing the example above
the
Rx
naming now makes more sense?The text was updated successfully, but these errors were encountered: