Coffeehouse Post

Single Post Permalink

View Thread: AsObservable Extension Method
  • User profile image
    Santa's Envoy

    Maddus Mattus said:
    Santa's Envoy said:

    I understand your logic, but I dont think it will work.


    For instance, you dont specify wich object to observe on. A event in itself is meaningless. It's the context of the event that provides the added value. A mouse move event is meaningless without the mouse object. So you cannot observe a mouse move event without an instance of a mouse.


    You are trying to create a static extension method for events. The static has no reference to the instance, so what is it listening to?

    What the extension method is supposed to do is simply return an Observable representation of the event, so you can access a richer set of functionallity. Contextual information is not lost because you can only obtain said Observable by calling the method on the event. The model we have available today (Observable.FromEvent<>) is much less intuitive (and much more verbose) than the extension method solution. Though the semantics aren't really my matter of interest. What I'm interested to know is why it can't be done. If it could, I'm pretty sure it would've.