Skip to main content

Questions tagged [observer-pattern]

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.

6 votes
2 answers
134 views

Observer pattern written in C++

I just carefully studied the observer pattern. And I wrote a demo snippet to better undertand it. I am not so sure that if it's the right way to define ...
John's user avatar
  • 469
4 votes
1 answer
103 views

My C++ Implementation of the Observer Pattern

I have written my own basic implementation of the Observer pattern. Please code review it as you feel. This is a one file implementation, and any feedback no matter how small is appreciated. One ...
Archie Payne's user avatar
5 votes
2 answers
228 views

Dependency problem with field changes

The Observer Pattern is used here to notify changes in a Person's data. For example, when age changes, the value of can_vote() ...
prestokeys's user avatar
  • 1,401
2 votes
2 answers
490 views

Generic observable type

I am writing an observer design pattern that is not too complex but I still feel there's a lot for me to learn about C++ be it little details (especially coming from C). A couple of observations: I ...
xyf's user avatar
  • 508
0 votes
1 answer
217 views

PyGame Event Handling

I'm new to pygame and tried to write my own Event Manager because I couldn't find a solution I was satisfied with. So I wrote my own inspired by the observer pattern: ...
lukstru's user avatar
  • 1,048
1 vote
1 answer
645 views

Multithreaded observer pattern in Rust

I often want to program in an event driven way, but classic implementations of the observer pattern often pose an ownership challenge, and they only get more difficult once multiple threads are ...
Blue7's user avatar
  • 373
1 vote
2 answers
101 views

Requests and handling requests

For this task, I don't think that the Observer Pattern can be used in its classic form. Those who have received the requests and those who choose to accept the request are not the same group. Those ...
prestokeys's user avatar
  • 1,401
1 vote
1 answer
327 views

Typescript simple observable state and web component

I've been experimenting with wiring up a vanilla web component in a reactive manner to a state box. The goal is that when something changes on the state object, the web component reacts. I realize ...
Jeff Putz's user avatar
  • 113
5 votes
3 answers
402 views

Observer Design Pattern in C++ to model magazine subscriptions

My attempt at a observer design pattern (I know using namespace std isn't good). I'm very new to design patterns. Everything is inline with class definition. Please tell me if I'm doing anything wrong ...
Asphodel's user avatar
3 votes
2 answers
755 views

Generic Observer/Listener implementation in Java

I am working on a personal project in university where I am currently trying to make my own implementation of a generic observer pattern that I can use throughout my project. I would appreciate any ...
Emil Holmsten's user avatar
4 votes
1 answer
347 views

Android BMI calculator using LiveData

I have made a Body mass index-calculator using ViewModel and LiveData. Source-code of the MainActivity: ...
michael.zech's user avatar
  • 5,044
1 vote
2 answers
1k views

C++ Observer Pattern with std::function

I am/we are using the observer pattern for many things in our application. I think it's time to create a reusable base class for these situations. Most implementations I could find only do something ...
Michael's user avatar
  • 13
3 votes
1 answer
574 views

Adjusting variables on change of status attribute of my Order Laravel model on the updated event in observer

I have an order model and a client model. A client has many orders, an order belongs to a single client. In the client model I keep track of how much money a client paid (...
Bogdan Ta's user avatar
3 votes
1 answer
164 views

Abstract wrapper for fundamental types

I have created this interface as part of my C++ learning path. This post inspired me a lot. The idea is to use its concrete implementations to perform some actions before and after any change of the ...
EmaPrn's user avatar
  • 31
1 vote
2 answers
867 views

Observer pattern in Rust

A simple implementation of the Observer pattern in rust. The Observable constructor (::new) is called with a subscription function which will be called every time ...
Luke Skywalker's user avatar

15 30 50 per page
1
2 3 4 5
7