/// <summary>
        /// WhenLoaded allows you to register a Func to be called OnViewLoaded.
        /// </summary>
        /// <param name="item">Object that supports viewEvents.</param>
        /// <param name="block">
        /// The method to be called when the corresponding View is loaded.
        /// It returns a list of Disposables that will be cleaned up when the View is unloaded.
        /// </param>
        /// <returns>A Disposable that cleans up this registration.</returns>
        public static IDisposable WhenLoaded <T>(this IViewFor <T> item, Func <IEnumerable <IDisposable> > block) where T : class
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            return(item.WhenLoaded(block, null));
        }
 /// <summary>
 /// WhenLoaded allows you to register a Func to be called OnViewLoaded.
 /// </summary>
 /// <param name="item">Object that supports loading.</param>
 /// <param name="block">
 /// The method to be called when the corresponding View is loaded.
 /// The Action parameter (usually called 'd') allows
 /// you to register Disposables to be cleaned up when the View is
 /// unloaded (i.e. "d(someObservable.Subscribe());").
 /// The Action parameter (usually called 'disposables') allows
 /// you to collate all disposables that should be cleaned up during unloading.
 /// </param>
 /// <param name="view">
 /// The IViewFor will ordinarily also host the View Model, but in the event it is not,
 /// a class implementing <see cref="IViewFor&lt;T&gt;" /> can be supplied here.
 /// </param>
 /// <returns>A Disposable that cleans up this registration.</returns>
 public static IDisposable WhenLoaded <T>(this IViewFor <T> item, Action <CompositeDisposable> block, IViewFor <T> view = null) where T : class
 {
     return(item.WhenLoaded(
                () =>
     {
         var d = new CompositeDisposable();
         block(d);
         return new[] { d };
     }, view));
 }
 /// <summary>
 /// WhenLoaded allows you to register a Func to be called OnViewLoaded.
 /// </summary>
 /// <param name="item">Object that supports loading.</param>
 /// <param name="block">
 /// The method to be called when the corresponding View is loaded.
 /// The Action parameter (usually called 'd') allows
 /// you to register Disposables to be cleaned up when the View is
 /// unloaded (i.e. "d(someObservable.Subscribe());").
 /// </param>
 /// <param name="view">
 /// The IViewFor will ordinarily also host the View Model, but in the event it is not,
 /// a class implementing <see cref="IViewFor&lt;T&gt;" /> can be supplied here.
 /// </param>
 /// <returns>A Disposable that cleans up this registration.</returns>
 public static IDisposable WhenLoaded <T>(this IViewFor <T> item, Action <Action <IDisposable> > block, IViewFor <T> view) where T : class
 {
     return(item.WhenLoaded(
                () =>
     {
         var ret = new List <IDisposable>();
         block(ret.Add);
         return ret;
     }, view));
 }
 /// <summary>
 /// WhenLoaded allows you to register a Func to be called OnViewLoaded.
 /// </summary>
 /// <param name="item">Object that supports loading.</param>
 /// <param name="block">
 /// The method to be called when the corresponding View is loaded.
 /// The Action parameter (usually called 'd') allows
 /// you to register Disposables to be cleaned up when the View is
 /// unloaded (i.e. "d(someObservable.Subscribe());").
 /// </param>
 /// <returns>A Disposable that cleans up this registration.</returns>
 public static IDisposable WhenLoaded <T>(this IViewFor <T> item, Action <Action <IDisposable> > block) where T : class
 {
     return(item.WhenLoaded(block, null));
 }