observer

How do I modify existing AS3 events so that I can pass data?

So I want a way to set up events so that I can pass data without creating closures \ memory leaks. This is as far as I have got: package com.events { import flash.events.Event; public class CustomEvent extends Event { public static const REMOVED_FROM_STAGE:String = "removedFromStage"; public var data:*; public f...

How you would you describe the Observer pattern in beginner language?

Currently, my level of understanding is below all the coding examples on the web about the Observer Pattern. I understand it simply as being almost a subscription that updates all other events when a change is made that the delegate registers. However, I'm very unstable in my true comprehension of the benefits and uses. I've done some go...

Observer Pattern and Delegates

I need help trying to understand the Observer Pattern and Delegates. I found this code on another website and I am trying to understand what it is actually doing. Can someone help me out. When I execute the code, I get both of the messages "Server is up and running" and "Server is down, We are working on it it will be back soon". I t...

Threaded implementation of observer pattern - C++

I'm developing a C++ program which has a "scan" method which will trigger a relatively long running scanning procedure. When the procedure is completed, the scan method will notify observers of results using the observer pattern. I would like to create a separate thread for each scan. This way I can run multiple scans simultaneously. W...

How is the Observer pattern different from an Event driven model?

I am a senior level developer but I haven't had a lot of formal training and I although I have used many design patterns and seen them used in my years as a developer, no one really went out of their way to say. "Oh this is an observer pattern, or this is a Singleton pattern." Reading over some of the design patterns, I came across the ...

How to handle different processing based on message type?

I have a process which has a "notify" method which receives as a parameter the base class of the message type. I'd like to do different processing based on the derived type of message. Does this mean I need to add a method called "process" or something similar to the message type, and invoke it using polymorphism? Is it better to add a "...

C# Plugin Architecture with interfaces share between plugins

Hi all, I divided my problem into a short and a long version for the people with little time at hand. Short version: I need some architecture for a system with provider and consumer plugins. Providers should implement intereface IProvider and consumers should implement IConsumer. The executing application should only be aware of IProv...

Need alternative to filters/observers for Ruby on Rails project

Rails has a nice set of filters (before_validation, before_create, after_save, etc) as well as support for observers, but I'm faced with a situation in which relying on a filter or observer is far too computationally expensive. I need an alternative. The problem: I'm logging web server hits to a large number of pages. What I need is a...

Should I add support for PropertyChangeSupport and PropertyChangeListener in a Java bean for a web application?

I noticed that some people write beans with support for the Property Change observer pattern. import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.Serializable; public class SampleBean implements Serializable { public static final String PROP_SAMPLE_PROPERTY = "sampleProperty"; priva...

How do I collect statistical information on application usage in ASP.NET MVC?

I'd like to collect statistical information, such as PageViews, Number of comments for each user, etc. I've thought about using the observer pattern. How would I implement this in ASP.NET MVC? ...

When should I remove observers? Error about deallocating objects before removing observers.

I am trying to use key-value observing in one of my classes. I register the observers in the init method and remove/deregister them in the dealloc, but I get the following error which seems to occur before my dealloc method gets called, according to my debug prints. An instance 0x583870 of class TekkPoint is being deallocated while key ...

Example of JavaScript observer pattern

Can anybody send me the good links of the observer pattern in JavaScript? ...

Problems implementing the "Observer" pattern

I have met an interesting problem while implementing the Observer pattern with C++ and STL. Consider this classic example: class Observer { public: virtual void notify() = 0; }; class Subject { public: void addObserver( Observer* ); void remObserver( Observer* ); private: void notifyAll(); }; void Subject::notifyAll() { ...

Observer pattern implemented in C# with delegates?

There is a question already answered which is http://stackoverflow.com/questions/32034/in-c-isnt-the-observer-pattern-already-implemented-using-events It asks if the observer pattern is already implemented in c# using events. While I get the events and observer pattern, isn't the observer pattern really just delegates and events is a f...

Method peaking my processor

Possible Duplicate: How do I start optimising my Java code? - CPU is at 100% I have a method isReset() that's executing like crazy i defined it as public boolean isReset() { return reset; } in another class. the class below is the only class that uses this code. import java.awt.BorderLayout; import java.awt.Dimension...

Design of listener for multiple events

I'm familiar with standard listeners, esp. in Java. For example, if you have a collection of objects, it might support a set of listeners for different things: CreateListener, ChangeListener, DeleteListener. Each has one method (e.g. objectChange) that is passed a list of affected objects. An app using this collection could register i...

Styles of adding / registering button listeners in OOP (Java, Actionscript, etc)

I've come across 2 different styles when adding button listeners in UI. I use SWT as example. But nonetheless I saw the similar code in J2ME, Flash Actionscript as well. style 1: b1.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { System.out.println("b1: "); } public void widge...

Problem with Observer Pattern and generics in Java

I have made a generic Observer interface and an Observable class, but can't compile my class due to some generics problem. I don't know precisely why what I'm trying to do is forbidden. The code follows: public class Observable<U> { private List<Observer<Observable<U>, U>> _observers = new ArrayList<Observer<Observable...

Best Publish/Subscribe "Middleware"

I'm in the market for a good open source network based Pub/Sub (observer pattern) library. I haven't found any I like: JMS - tied to Java, treats message contents as dumb binary blobs NDDS - $$, use of IDL CORBA/ICE - Pub/Sub is built on-top of RPC, CORBA API is non-intuitive JBOSS/ESB - not too familiar with It would be nice if su...

Observer pattern Or DataBinding

Hello all, My question is, would you implement the Observer pattern, or use databinding to do the following: At the moment, i'm initializing a list of GuiDataObj. When an event is triggered, I look up the GuiDataObjById and then modify the object, which is databound to a GuiElement; which updates the GUI. There are several GuiElement...