observer

Run a method everytime value changes.

Hi, I wonder if any of you guys can help me with what I think is observing problem. I have an element (svg to be more specific) that I want to update every time a value somewhere is changed. I have variable: GetThreadTree().treeBoxObject.getFirstVisibleRow() that initially is 0. I want to run a function updateCanvas() every time valu...

How to implement the Observer pattern with Java RMI?

I have a client that starts a long running process on the server. At regular intervals, I'd like to show the user what's happening in the background. The most simple approach is to poll the server but I'm wondering if there wasn't a way to implement the Observer pattern for this. Unfortunately, I'm using RMI to talk to the server and I f...

Alternative design pattern to Observer for .Net

I was initially going to implement an observer pattern in C# 3.0 to solve my problem although it wouldn't be implement exactly in the same way. My problem is that I have a web application with users who can post messages. Notifications do not go directly to other users but to a distributed cache where a statistics objects are updated an...

using both :url and :function on observe_form

Is there a way to generate both a Javascript function call and an Ajax call in the same observe_form tag? For example, something like this: <%= observe_form 'user_filter_form', :url => { :action => :process }, :function => :fix_fields %> Thanks!! ...

Equivalent of Django Signals for Rails?

In Rails, the closest I've seen to Django Signals are Observers. The problem with them is that they're restricted to triggering callbacks on hardcoded events related to a model's lifecycle. Django signals can be created anywhere, triggered anywhere and handled anywhere. The model lifecycle callbacks are just regular signals that happen ...

Super-simple example of C# observer/observable with delegates

Hi I recently started digging into C# but I can't by my life figure out how delegates work when implementing the observer/observable pattern in the language. Could someone give me a super-simple example of how it is done? I have googled this, but all of the examples I found were either too problem-specific or too "bloated". ...

Is it OK for a class to be observable and an observer ?

Had a code smell moment and couldn't decided if its OK for a class to be Observable and also an Observer, so thought I'd post here. class ObservableAndObserver extends Observable implements Observer { // Class is ofcourse registering and receving notifcations on different events // effectly actving as a middle man. // Is this a pa...

How to trigger an event on payment received in magento?

Greetings, in Magento I want to trigger an event, once an order has been set to processing (by gateway confirmation or manually) that, example: If a general customer (id 1) spends over 100$ and the payment has been confirmed, set his group id to 4 (silver VIP, which by promotion rule gets 2% discount globally) I would give a bounty to th...

Observe a File or Folder in Objective-C

What is the best way to listen to a folder or file to see if it has been saved or if a new file has been added? ...

Observer in a distributed environment

Machine A needs to send a message to machine B. Machine A has a static IP but machine B does not. One option I could think of to solve this problem is that machine B opens a TCP connection to machine A and then machine A sends the data/message to machine B. However, this solution has the following limitations: a) It is not scalable if ...

How granular should you make your Observables/Listenables?

You have a pull-oriented Observable/Listenable which notifies Observers/Listeners when some state changes. The state consists of more than one nugget of data, and some of your Observers/Listeners don't care about the whole state. Do you generally prefer to notify all the Observers/Listeners anyway and allow them to ignore notifications...

Update: How to find event listeners on a DOM node in prototype?

I'm looking for an updated answer to this question. It seems that Event.observers is no longer used (perhaps to avoid memory leaks) in Prototype 1.6+, so how do I track down now what event listeners are attached to an element? I know Firebug has a "break on next" button, but there are several mouse listeners on the body element that e...

In Rails, a Sweeper isn't getting called in a Model-only setup

I'm working on a Rails app, where I'm using page caching to store static html output. The caching works fine. I'm having trouble expiring the caches, though. I believe my problem is, in part, because I'm not expiring the cache from my controller. All of the actions necessary for this are being handled within the model. This seems like i...

Persistence Pattern - Rule based Observer

I'm trying to add functionality to an app where a user can subscribe for changes made either: To another entity (by any user) By another user (to any other entity) A combination of the two (this last one's optional, but makes the problem more challenging) I'm wondering how best to persist these rules to the database. I'm naturally t...

Observer over a network

I want to have an event driven architecture where the event consumer (subscriber/observer) and the event producer (publisher/subject) are over a distributed geography. Is there something in .NET that relays events over a network seamlessly without my having to plumb into the implementation of the transport mechanism? I recall Juval Low...

Java observer and observable

Can anyone explain why the update method on printobserver is not being called when I click the button on this JFrame? import java.awt.BorderLayout; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import java.net.InetAddress; import java.net....

Observers vs. Callbacks

Hey, i thought about using observers or callbacks. What and when you should use an observer? F.e. you could do following: # User-model class User << AR after_create :send_greeting! def send_greeting! UserNotifier.deliver_greeting_message(self) end end #observer class UserNotifier << AR def greeting_message(user) ... ...

How do I use the livevalidation javascript library custom.validation function ?

(note: my original question was not linked to my openid - I am reposting here to be able to edit/update/respond accordingly - if anyone with access could remove the original question: /questions/1554916/how-to-use-the-livevalidation-javascript-library-custom-validate-function that woudl be great !!) Heya Folks, I am very new to all of ...

Generic Obeserver Pattern for User Controls

Hi there, I want to implement a generic Observer Pattern for user controls. What is the best way to do this? There are 3 usercontrols: A, B & C. Each of these usercontrols is a representation of a set of data. Each control has a select for display mode (basic or detailed). The site visitore gets to choose which mode. On changing the ...

Event aggregator and collections

Hi, i want to use an event aggregator to syncronize my viewmodel with the view (the viewmodel ovservs the model), this is very simple to implement in the model, simply call notify on the setters of the properties. but it gets more complicated when the model has collections. where should be the code which will call notify? what would be ...