Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [observer-pattern]

The tag has no usage guidance.

-1
votes
0answers
58 views

Is There a Pure Pull Relational Reactive Programming Platform?

An aspect of evaluation scheduling appears in various disciplines under different names. If you are familiar with any of these pairs, focus on your experience with those pairs to understand the topic ...
7
votes
2answers
816 views

API Design - Observable vs Callback

We as a team are writing an C# SDK which communicates with a Server endpoint. All our API's till now have been Task based. Like Task DoOperationAsync() Recently we across a need for API which gets ...
3
votes
1answer
290 views

Is Content Observer an implementation of Observer Pattern?

Observer Pattern is defined by the 'Gang of Four' Design Patterns book as a "one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated ...
0
votes
0answers
16 views

How should Selection selectfinish/selectend event be implemented?

I'm looking to do something whenever a user finishes making a selection —essentially, on the first mouseup event after every selectstart event, I think— on the page. I want to take that selection and ...
2
votes
4answers
152 views

Using Observer Pattern to selectively act on events

I'm currently in the process of architecting a small RPG-style dungeon crawl (in Unity), and am a little stuck on how to update various objects when things change, while not updating unrelated objects....
0
votes
0answers
224 views

What is the cleanest way to model my domain in JavaScript?

I am building an SPA. It will use WebGL, Canvas and SVG for certain components, and html for rendering views. I have a messaging system setup to define messages coming from a server, which will get ...
6
votes
3answers
1k views

When building an observer pattern (event pattern) is it better to use classes or an enum for events?

When building an Observer pattern, you need to define your events that the are broadcast and observed. Is it better to define an abstract Event class with multiple subclasses for each event, or to ...
0
votes
0answers
376 views

How should I code a multi-type observer pattern?

We have some states, depending on a window that is currently active: public enum LoginState{ NONE, LOGGIN_IN, LOGIN_SUCCESS, LOGIN_FAILED } public enum LobbyState{ NONE, ...
3
votes
1answer
364 views

Connect observers to observable automatically using dependency injection container

I have several services that implement an observer interface and one service that implements the corresponding observable interface. I'm currently using unity together with Prism so I would prefer to ...
1
vote
1answer
151 views

What's a good robust way to query processes for their help or framework origin especially in Windows?

What's a good robust way to query processes for their help or framework origin, especially in Windows? I've got an automated testing module that queries binaries that fit a special name pattern with -...
3
votes
1answer
582 views

Implementation of observer pattern with one observer/multiple publishers and multiple events?

I'm in a bit of a tricky situation where I need to use the Observer pattern but I don't really know the best way to go about it. Here's a quick briefing on my application: I'm implementing a GUI ...
4
votes
1answer
140 views

State propagation(bottom-up) in multi-walk tree

Using the Tree representation(mentioned below), typedef enum {Running, Warning, Critical}Status; struct TreeNode; typedef struct List{ int childCount; struct treeNode **childList; }List; ...
2
votes
1answer
598 views

Observer pattern for rest services with UI client

I am developing restful services using resteasy for an application. This application has UI which will consume these rest services. Now I am having a case where I have to do a server push to UI(...
0
votes
1answer
74 views

Mutual observer

I want my Wire objects to be in connection with Port objects. That is Port has a list of connected wires and method Port.add(wire). Similarly, Wire has list of ports it is connected to and Wire.add(...
4
votes
4answers
207 views

Using ObserverPattern, but need to stop some observers displaying changes immediately

In a GUI application (to organize images), I use the Observer Pattern (or anything similar to model-view-(view)controller) to inform other components about changes. Assuming three components A, B, C ...
0
votes
1answer
80 views

Can I call DOM event handling an instance of observable/observer pattern

In the following DOM event handling example (using jQuery): $('#shopping-cart').on('click', function(event){...}); could I not call the shopping-cart DOM element the observable, and the function the ...
2
votes
1answer
2k views

What are the advantages of Observables over an iterable of futures?

I recently came across the ReactiveX pattern for asynchronous data-flows. I studied the information provided there and also watched this talk by a Netflix engineer on how they used Observables to ...
2
votes
1answer
462 views

Observer Design Pattern with complicated objects

I am trying to currently get a good grasp on the Observer design pattern, but I am stuck wondering about one specific issue. In the examples I have been able to find of implementation, they are all ...
9
votes
2answers
1k views

Is the observer pattern suitable when the observers are not independent of each other?

I have a class Car which has 2 properties: int price and boolean inStock. It also holds a List of abstract class State (empty class). There are 2 states which can be applied on the car and each is ...
0
votes
2answers
334 views

Is this example implementation of the Observer pattern well-written?

It seems as if this example implementation of the Observer pattern is drawn from the book Headfirst Design Patterns, OReilly, which I am currently reading. Here is a UML diagram from the book It's ...
5
votes
4answers
618 views

Is it true that for Observer Pattern to work, there probably is some polling mechanism underneath?

The short question is: is it true that for Observer Pattern to work, there probably is some polling mechanism underneath? (update: in a network situation) It was quite amazing that if on my Macbook ...
1
vote
1answer
293 views

Should listener interfaces be nested?

In Java the observer pattern is implemented with at least one interface (often ending in Listener or Observer). Such interfaces can be placed nested inside the class or be separate, for example: ...
3
votes
1answer
2k views

Observer for two independent events in the observable class

Observer pattern aim: the observer class responds to the changes of the observable class state. Problem. There are different processes inside observable class that should be observed. Those events ...
15
votes
1answer
8k views

Difference between Consumer/Producer and Observer/Observable

I am working on the design of an application that consists of three parts: a single thread that watches for certain events happening (file creation, external requests etc.) N worker threads that ...
4
votes
1answer
1k views

In MVC, who is in charge of handling observers?

(I'm writing a large MATLAB GUI that makes significant use of MVC, so my example is written in MATLAB. However, I believe this question is language-agnostic. Please correct me if I'm wrong.) I have a ...
1
vote
3answers
519 views

C# Subject Observer Architecture question

I'm making a C# application using the Subject Observer design pattern in a slightly different way. I am passing the Provider Class, implementing IObservable (this has the OnNext() method that ...
1
vote
2answers
764 views

Observer pattern without state change?

My question is whether there is a similar pattern to Observer that does not imply a state change in the observed object. The following is a concrete example: I have a ConnectionFactory class which is ...
1
vote
2answers
1k views

Observer pattern: Prevent multiple firings on changed internal property

I have an object Foo that has 2 public properties: A and B. These properties can be changed from outside, as the application I'm working on is using a data-binding architecture. This is the front-...
1
vote
3answers
436 views

Potential abuse of observer pattern

I have a MeetingRoom object that contains a list of Employees, there is a function on each employee called SetMeetingDate, this method has to take into account the state of all other employees in the ...
3
votes
4answers
186 views

Two user inputs that alter each other

I have a user interface with two numeric input boxes, send amount and receive amount. The values are in different currencies and are related by an exchange rate. That is, receive amount should always ...
1
vote
1answer
548 views

Does key-value observing between model and view violate MVC?

In MVC the Controller is the go-between for the View and the Model. So the Controller should be the one that observes or receives changes from the Model and View and updates the other accordingly. I ...
2
votes
2answers
620 views

What preconditions should be checked while adding/removing a listener?

Imagine the following interface: interface Service { addListener(Listener l) removeListener(Listener l) } Should I check for null values while add/remove? Is it a good idea on remove to ...
1
vote
1answer
250 views

Software to access GSM Terminal, sending and receiving AT commands, validating results

I am currently implementing a software that uses a GSM terminal to perform actions. Actions can be sending messages, checking balance, receiving status report messages, setting the pin, ... The ...
0
votes
3answers
931 views

Are EventHandler<T> and IObservable<T> interchangable?

I have an object which will periodically raise an event based on an action performed in an application. This will be heard by any listener(s) and acted upon accordingly. I do not wish to use a ...
2
votes
2answers
1k views

Any OOP design pattern that is somewhat representative of all of the SOLID OOP design principles at play?

I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one other....
7
votes
1answer
8k views

The Observer pattern using the pulling mechanism

I was wondering about the following implementation of public void update(Observable obs, Object arg) while i want to send to all of my observer and update using notifyObserver() i and passing a ...
3
votes
1answer
870 views

I'm always reimplementing observer/subject code in Java. Is there a better option?

I'm always writing observer/subject interfaces in a particular Java project, e.g.: /** * Registers the receiver to the dispatcher. * When data arrives that the receiver can process, * it will be ...
1
vote
1answer
156 views

Freeing Memory: Observer Pattern?

I am building a scientific application in matlab which handles several hundred large matrices (large as in 'very few of these will fit into ram'). Each matrix is contained within a dedicated object to ...
9
votes
4answers
4k views

Was .NET's IObserver<T> intended for subscribing to multiple IObservables?

There are IObservable and IObserver interfaces in .NET (also here and here). Interestingly, the concrete implementation of the IObserver does not hold a direct reference to the IObservable. It doesn'...
3
votes
2answers
792 views

UML class diagram: how to annotate observer-subject relationship?

How can I annotate in a UML class diagram that an instance of ClassA is registered as an observer of an instance of ClassB? (Both implement the appropriate interfaces). This doesn't really belong in ...
2
votes
0answers
459 views

Observing multiple observables at once / Network of chained observers

Quick example: HM observes CM SM observes CM HSM observes HM and SM, but wants to be updated only after both have their new value derived from CM. More detail: (this is still a made-up example, but ...
0
votes
1answer
467 views

Observer pattern: “Web of observers” - Is this ever in use?

I had an idea (which I'm sure already exists), to create a sort of 'network of observers/subjects'. I would like to describe how it works and than ask several questions about it. Say we have 5 ...
3
votes
3answers
2k views

How does Observer create loosely-coupled design?

I completely understand the Observer design pattern, what it is for and how to implement it. I also understand what the term 'loosely-coupled' means. But I'm not sure how Observer makes designs more ...
2
votes
2answers
654 views

Is there a way to not use the Observer pattern when creating GUI systems?

In Java, the Swing library implements the Observer/Subscriber-Publisher design pattern to design the way the program responds to events on the GUI (button clicks, etc). The programmer registers ...
1
vote
3answers
740 views

Does this in the Observer pattern count as composition?

In a classic implementation of the Observer design pattern, the subject has a list of references to all of it's observers, and each observer might have a reference to it's subject. Is this considered ...
3
votes
1answer
194 views

Testing: Should I wrap system notifications and send my own?

In the current Cocoa app I'm working on, I've got an object, RecordScheduler, which responds to two types of notifications, "day did pass" and "quicksaving interval did pass". In both cases, the ...
2
votes
2answers
820 views

observer class as instance

Sometimes I read in observer-pattern descriptions, to make the constructor of a observer base class protected so the class will be abstract. but by making the constructor public (if even one is ...
9
votes
4answers
19k views

Which design pattern is more suitable for logging?

I should log some events in a program but as far as I know it would be better to keep the logging code outside the program because it is not about the real functionality of the program. So may you ...
1
vote
1answer
514 views

how to model a connection to a resource, with rudimentary event processing

For my simple MUD client I'm using Apache Telnet (no, not ssh). A mud client is a strange beast: Generally, a MUD client is a very basic telnet client that lacks VT100 terminal emulation and the ...
5
votes
1answer
3k views

Design patterns for multi-threaded messaging server

I'm designing an instant messaging server as a personal exercise to improve my understanding and application of multi-threading and design patterns in Java. I'm still designing, there's no code yet. ...