The recording of the first ever ReactiveUI virtual conference is available on our YouTube Channel.

Observable.Using<TSource, TResource>()

Observable.Using<TSource, TResource> Method

Constructs an observable sequence that depends on a resource object.

Namespace:  System.Reactive.Linq
Assembly:  System.Reactive (in System.Reactive.dll)


Public Shared Function Using(Of TSource, TResource As IDisposable) ( _
    resourceFactory As Func(Of TResource), _
    observableFactory As Func(Of TResource, IObservable(Of TSource)) _
) As IObservable(Of TSource)
Dim resourceFactory As Func(Of TResource)
Dim observableFactory As Func(Of TResource, IObservable(Of TSource))
Dim returnValue As IObservable(Of TSource)

returnValue = Observable.Using(resourceFactory, _
public static IObservable<TSource> Using<TSource, TResource>(
    Func<TResource> resourceFactory,
    Func<TResource, IObservable<TSource>> observableFactory
where TResource : IDisposable
generic<typename TSource, typename TResource>
where TResource : IDisposable
static IObservable<TSource>^ Using(
    Func<TResource>^ resourceFactory, 
    Func<TResource, IObservable<TSource>^>^ observableFactory
static member Using : 
        resourceFactory:Func<'TResource> * 
        observableFactory:Func<'TResource, IObservable<'TSource>> -> IObservable<'TSource>  when 'TResource : IDisposable
JScript does not support generic types and methods.

Type Parameters

  • TSource
    The type of source.

  • TResource
    The type of resource.


  • resourceFactory
    Type: System.Func<TResource>
    The factory function to obtain a resource object.

  • observableFactory
    Type: System.Func<TResource, IObservable<TSource>>
    The factory function to obtain an observable sequence that depends on the obtained resource.

Return Value

Type: System.IObservable<TSource>
The observable sequence whose lifetime controls the lifetime of the dependent resource object.

See Also


Observable Class

System.Reactive.Linq Namespace