observer

Scala Listener/Observer

Typically, in Java, when I've got an object who's providing some sort of notification to other objects, I'll employ the Listener/Observer pattern. Is there a more Scala-like way to do this? Should I be using this pattern in Scala, or is there something else baked into the language I should be taking advantage of? ...

Multithreading or observer pattern when waiting for dns lookup?

Hi, I'm designing a system in java which utilizes a dns lookup class. My question is, when calling the class's dnsLookup(), whether to do it in a new thread or use the observer pattern and let the dns class tell me when it's done. This isn't a problem as long as the lookup returns a value almost instantly but when it takes a few seco...

Weld - Asynchronous Event Observers

Hi all, I am using Weld to observe events. I thought there was a way to specify if the observer was asynchronous or not, but I am not finding that annotation or documentation. Can observers be asynchronous, if so, what do I need to do to make that happen? Thanks, Walter ...

Magento: How do you disable or change how a core observer method works

I have been wondering about this for a while. What if Magento has written a core Observer class and performs a functionality that you do not want it to execute, or you want to rewrite it? Is there a way to say, don't use this method in an Observer, just use mine. If I setup a method for my own Observer won't it just do the core functiona...

Rails 3 Observer -- looking to learn how to implement an Observer for multiple models.

Hello, I'd like to add an Auditor Observer which does an action anytime after_create for 3 models (books, characters, authors)... I recently heard of the Observer capability but can't find any documentation on the ability. Is it support in Rails 3? How do I create an Auditor Observer that does something after_create for 3 models? Than...

C# Observer pattern: Still tightly connected?

ok, so I am stuck at the observer pattern here, almost all tutorials I read tell the subject class to subscribe the observer(s). But with encapsulation in mind, how is this not tighlty coupled? They still depend on each other know, don't they? What I mean to say is that the subject Class must know the observer object to add him to the ...

What is the difference between the Observer and Subject-Observer patterns

While watching some videos on Channel 9 about the Reactive Extensions for .NET, someone asked whether the Reactive Extensions library is an implementation of the Observer pattern. The presenter then went on to answer by saying that the library is an implementation of the Subject Observer pattern. This leads me to believe that there is po...

CDI - is the caller notified when an observer observes an event?

Hi all, I am using CDI and want to know how the caller is notified that the observer has observed an event or didn't. If no observes act on that event, then I want to do something. I don't see this being documented anywhere in the documentation other than there was a hint that the caller is notified. Thanks, Walter ...

Determine what attributes were changed in Rails after_save callback?

I'm setting up an after_save callback in my model observer to send a notification only if the model's published attribute was changed from false to true. Since methods such as changed? are only useful before the model is saved, the way I'm currently (and unsuccessfully) trying to do so is as follows: def before_save(blog) @og_publishe...

Is there a Rails way to check which attributes have been updated in an observer?

I have an ActivityObserver, which is observing tasks, and has an after_update callback. I want to test if a particular attribute has been modified in the update. Is there a Rails way to compare the attributes of the subject with what they were before the update, or to check if they have changed? ...

(OleDb) Detection of small disconnection (c#)

Hello, I have to create a .NET project to monitor some oledb connections, I explain: my client have lots of big winform(c#) projects that use some class (witch contain oledb variable) and these projects crashes when a disconnection (due to network or database,...) occur , to avoid this problem, I can't resolve all these projects (too ...

Events not firing/or observer not working in magento

Hello, I have a module which listens to a few events. It works fine in at least a dozen installations I have tested it on. On on specific installation, a client which I installed it, on Magento version 1.4.1.1, It does not work. When I tested his system, and I fire the events manually, eg Mage::dispatchEvent('..') the observer does lis...

Changing Core Data Items crashes App

Hey Guys, I am running into another problem with my Iphone App which I just can't solve myself. I implemented a kind of organizer functionality in my latest app. There one can create appointments which are displayed in a tableview and persisted in a CoreDataStore. I use 4 classes: an overview where appointments are displayed a view ...

Javascript - Prototype: Event.observe on a form is not working for IE

I have this JS which gets a XML response from a service, its a True or a False, well the script should catch the submit and get the response from the service. The problem is that I see that its not working because when I do the submit, I see the XML response on IE (6/7/8), when the script should have catched it and validated the XML resp...

pass function in json and execute

Is there any way that I can pass a function as a json string (conversion with JSON.stringify), send it to another function, parse the json and then execute the function that was in the json? I am using jquery and javascript. ...

Release a listener / observer in Objective-C?

Hi guys! I'm not sure when it's the right moment to RELEASE a listener object. I have a object A that uses NSURLConnection's initWithRequest method to retrieve some URL. initWithRequest requires a delegate to listen after the events of dataReceived... So object A creates an object B and passes it as a delegate for initWithRequest metho...

RSpec sends emails (not storing in ActionMailer::Base.deliveries) - dont know why?

Hey, Im using rspec and when i run rake spec, the user mailer sends email through smtp and not stores the email in the ActionMailer::Base.deliveries-array (invoked by an user-observer)... Could you give me a hint why? # Rails version rails -v => Rails 3.0.1 # Ruby version with rvm (rvm version 1.0.16) ruby -v => ruby 1.9.2p7 (2010-09...

How to call a method before the mehtod of requested controller is executed : magento

Hello Experts, I want to call a method before the execution of every and each controller's method. I don't want to go and call the method in every method. I just want to call it from one place and it will be called before any method of any controller in magento. And I am sure we can do this but I don't know how it can be accomplished. ...

Android - why ContentObserver invokes itself?

Hi, I am trying to delete received SMS in ContentObserver (on "content://sms/") onChange() method using contentResolver.delete, but after deleting ContentObserver is invoked one more time. Could you explaing my, whe ContentObserver invokes itself despite deliverSelfNotifications() returns false? I foud soultion to uregister ContentOb...

Avoid multiple loop in Observer code

I have a class AllListener to encapsulate multiple Listeners as follows. The problem is I have to write a loop in each event method(onStart(), onEnd()). It's quite normal way in observer pattern code, but it's bad smell. Any better way to write loop once? Thank you! class AllListener{ List<Listener> listeners; void onStart(){ ...