1
0

Observable.Events.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using UniRx.Operators;
  3. namespace UniRx
  4. {
  5. public static partial class Observable
  6. {
  7. public static IObservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(Func<EventHandler<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler)
  8. where TEventArgs : EventArgs
  9. {
  10. return new FromEventPatternObservable<TDelegate, TEventArgs>(conversion, addHandler, removeHandler);
  11. }
  12. public static IObservable<Unit> FromEvent<TDelegate>(Func<Action, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler)
  13. {
  14. return new FromEventObservable<TDelegate>(conversion, addHandler, removeHandler);
  15. }
  16. public static IObservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(Func<Action<TEventArgs>, TDelegate> conversion, Action<TDelegate> addHandler, Action<TDelegate> removeHandler)
  17. {
  18. return new FromEventObservable<TDelegate, TEventArgs>(conversion, addHandler, removeHandler);
  19. }
  20. public static IObservable<Unit> FromEvent(Action<Action> addHandler, Action<Action> removeHandler)
  21. {
  22. return new FromEventObservable(addHandler, removeHandler);
  23. }
  24. public static IObservable<T> FromEvent<T>(Action<Action<T>> addHandler, Action<Action<T>> removeHandler)
  25. {
  26. return new FromEventObservable_<T>(addHandler, removeHandler);
  27. }
  28. }
  29. }