Browse Source
Rather than adding a TakeUntil(control.StyleDetach) to each applied style, keep track of the applied styles in a static list. This dramatically reduces memory usage.pull/471/head
15 changed files with 124 additions and 27 deletions
@ -0,0 +1,41 @@ |
|||||
|
// Copyright (c) The Perspex Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Reactive.Disposables; |
||||
|
|
||||
|
namespace Perspex.Reactive |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Provides common observable methods not found in standard Rx framework.
|
||||
|
/// </summary>
|
||||
|
public static class ObservableEx |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Returns an observable that fires once with the specified value and never completes.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="T">The type of the value.</typeparam>
|
||||
|
/// <param name="value">The value.</param>
|
||||
|
/// <returns>The observable.</returns>
|
||||
|
public static IObservable<T> SingleValue<T>(T value) |
||||
|
{ |
||||
|
return new SingleValueImpl<T>(value); |
||||
|
} |
||||
|
|
||||
|
private class SingleValueImpl<T> : IObservable<T> |
||||
|
{ |
||||
|
private T _value; |
||||
|
|
||||
|
public SingleValueImpl(T value) |
||||
|
{ |
||||
|
_value = value; |
||||
|
} |
||||
|
|
||||
|
public IDisposable Subscribe(IObserver<T> observer) |
||||
|
{ |
||||
|
observer.OnNext(_value); |
||||
|
return Disposable.Empty; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue