Questions tagged [observer-pattern]

A design pattern in which an object, called the subject, maintains a list of its dependents, called observers and notifies them automatically of any state changes, usually by calling one of their methods. It is one of the Gang of Four's behavioral design patterns. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

The Observer pattern (a subset of the publish/subscribe pattern) is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems.

This is one of the Gang of Four's behavioral , first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".

References:

1815 questions
0
votes
1 answer

Observer pattern with immediately notify

I have an API that exposes some events when its internal data changes. When someone wants to watch for data change, it attaches an event callback and API notifies it when the data changes internally. When state is changed and someone initializes…
Adam Szmyd
  • 2,765
  • 2
  • 24
  • 32
0
votes
0 answers

Add observer to shared library

In my current implementation I have a shared library (CameraControl.dll - used with implicit linking) which when triggered takes pictures and saves them in a local storage. The new functionality I'm trying to implement requires to get the picture…
Alex
  • 37
  • 1
  • 8
0
votes
0 answers

Maintaining session information while using Observer Design Pattern in Java

I am using the Observable and Observer classes from java.util package. I have the following in my Observable class public class IfxHistoryObservable extends Observable { public void inputHistoryUpdate( SomeDto inputHistoryDto, …
kosta
  • 4,302
  • 10
  • 50
  • 104
0
votes
1 answer

C++ sample Observer Template Class error

I am creating observer template sample in C++ on windows. Here there is an agent which has a list of customers. Whenever an entity(variable x) of the agent changes it notifies its customers about the same and passes the value of x to customers. The…
RKum
  • 758
  • 2
  • 12
  • 33
0
votes
1 answer

Clone all 'observe' of a cloned element using Prototype

I have a sortable list (done using prototype and scriptaculous): you can sort its elements or drag them into another list. When I drop the element (let's call it ELEMENT_1) of a list into another one what I do is a 'clone' of the dropped element and…
AldoB
  • 381
  • 1
  • 6
  • 15
0
votes
1 answer

what pattern or process to notify multiple systems about changes in another system

Imagine a system X with an http api with a lot of data from a (mysql) database. Imagine multiple systems being dependent on this data but doing very different tasks. Some work on one data-set others work on a huge bunch of data-sets. The data…
steros
  • 1,794
  • 2
  • 26
  • 60
0
votes
1 answer

Keeping a TableView updated with the Observer Pattern

I'm writing a JavaFX application. I have a TableView with all entries from a database, populated as follows: public class AdvertisementListController { @FXML public TableView advertisementTable; @FXML public…
Robb1
  • 4,587
  • 6
  • 31
  • 60
0
votes
5 answers

Rails Design Guidance: Limit User Actions to X Occurrences / Day, Notify Moderators and Users of Certain Actions

I'm working on a web app where people can save records using an industry-specific taxonomy. Most of my users will be familiar with it, but some may not be, or they may be rusty... etc. I have some required fields in these records where I'd like to…
0
votes
2 answers

Observer pattern update parameters

Why does the Observer interface has Observable o as a parameter? Do you recommend using Javas existing classes (implements Observer; extends Observable)? public class Test implements Observer { void update(Observable o, Object arg); }
0
votes
1 answer

Moving a circle on a map using Observer pattern

I have a (probably an easy) problem with my java program. I'm trying to create a circle that will move from one place to another. The map is a part of an easy dialogue game that says "go here" and the map should react to it. It has to be using an…
0
votes
1 answer

Swift tvOS: Getting the screen center for AVPlayerView

I am writing an app for tvOS that launches videos from URL's into an AVPlayerView, which is not nested in another View. The trouble is, the user had no idea anything was going on while loading was occurring, so I wanted to add an activity indicator…
D. Pratt
  • 444
  • 8
  • 15
0
votes
1 answer

C# handling user interaction in MVC

I have an implemented MVC Pattern and am thinking about Error handling and catching user decissions. My current approach is: create for every decissiontype an Event Hook and let the GUI View (in my case the Form) create a specific User interaction…
FrankM
  • 541
  • 3
  • 15
0
votes
1 answer

Observers don't get called using NotificationCenter Swift 4.0

I have a two ViewControllers: ViewController and SecondViewController. I added an observer to this two ViewControllers. In ViewController I also defined an IBAction to post the notification. I handle the notification via a closure in both…
user1895268
  • 1,559
  • 3
  • 11
  • 23
0
votes
0 answers

Updating a View according to a Model's new data - without engagement of a Controller

I would like to feel comfortable with the MVC concept but what I am lacking therefore is the link between the Model and the View. All the Information on this Topic seem to be based on events to happen and to be handled but what I need is a link…
0
votes
1 answer

Observer/Observable Help!

Greetings, I have been studying Obserser/Observable implementation to Model-View-Controller. I may also misused the pattern but here's what I've done so far. In my code. When Submit was press, it triggers the makeChange() of the Model. But never…
Cyril Horad
  • 1,555
  • 3
  • 23
  • 35