Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5934773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:09:39+00:00 2026-05-22T15:09:39+00:00

Say I am using the following interface (assume we can’t change our implementation to

  • 0

Say I am using the following interface (assume we can’t change our implementation to make it IObservable<T> as well as IProperty<T>).

public interface IProperty<T> {
    T Value { get; set; }
    event Action ValueChanged;
}

I am trying to observe the collection of Ts generated as the value changes. Because the event is declared as Action rather than the standard .NET event pattern I don’t think I can use Observable.FromEvent(...).

I’ve come up with a wrapper that seems to work, but as an Rx newbie I’m sure I’m missing some built in abstractions (or am possibly just doing the whole thing wrong).

Is there any way to do this using built in Rx functionality? If not, is my wrapper missing any obvious abstractions, or is there a completely different approach I should be taking?

//Example wrapper
public class ObservableProperty<T> : IObservable<T> {
    private readonly IProperty<T> _property;
    public ObservableProperty(IProperty<T> property) { _property = property; }

    public IDisposable Subscribe(IObserver<T> observer) {
        Action action = () => observer.OnNext(_property.Value);
        _property.ValueChanged += action;
        return Disposable.Create(() => _property.ValueChanged -= action);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:09:40+00:00Added an answer on May 22, 2026 at 3:09 pm

    This should do it:

    public static class RxExt
    {
        public static IObservable<T> FromMyEvent<T>(this IProperty<T> src)
        {
            return System.Reactive.Linq.Observable.Create<T>((obs) =>
            {
                Action eh = () => obs.OnNext(src.Value);
                src.ValueChanged += eh;
                return () => src.ValueChanged -= eh;
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a textbox in HTML using the following code: <input type=text name=text
I'm using the following code to do a checksum of a file which works
I'm using the following code to take the value of one field, subtract it
Let's say we have a Lucene index having few documents indexed using StopAnalyzer.ENGLISH_STOP_WORDS_SET .
Please Explain the following code #include <iostream> using namespace std; int main() { const
I'm using declarative J2EE form based authentication in my webapp, following the instructions given
I have started following Test Driven Development and find it very logical and helps
I'm currently using the boost threadpool with the number of threads equal to the
I'm creating javascript Variable using c#.net inside code behind page and putting that variable
I've just created a new data service using the WCF Data Services 4.1 CTP2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.