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.

Filter by
Sorted by
Tagged with
7 votes
0 answers
245 views

Scheduler built with observables v2 (follow-up)

It would probably be too easy if the old Scheduler worked as intended being that simple. But an eye-openig review showed that from time to time it'll miss one ...
t3chb0t's user avatar
  • 44.1k
5 votes
2 answers
1k views

Scheduler built with observables

I sometimes have to schedule some tasks and wanted to have my own reusable scheduler. Since I like the Rx, I build it on top of it. Follow-up There is a newer version of the ...
t3chb0t's user avatar
  • 44.1k
7 votes
1 answer
393 views

Threadsafe oneshot-event which fires on subscription if the event was fired in the past

Assumptions Basically, a Connection class has a "Disconnect" event. Subscribing to this event isn't thread-safe, because the disconnection may fire from another thread right before I subscribe. So ...
Oachkatzl's user avatar
  • 173
7 votes
1 answer
3k views

Message bus in C#

I wrote a MessageBus class whose only purpose is to deliver messages from object to object without direct link between them. I encountered a problem with duplicate ...
Bohdan Yarema's user avatar
7 votes
1 answer
190 views

JS stopwatch using the observer pattern

I'm learning OOP and also trying to learn and implement some design patterns. This question is a follow-up of Stopwatch interface OOP (Vanilla JS) The app is available in https://nacho-p5.github.io/ ...
nabla-f's user avatar
  • 163
6 votes
1 answer
2k views

Observable template in modern C++

I'm trying to create a modern template class for a generic observable: ...
Matias Suarez's user avatar
5 votes
1 answer
4k views

Implementation of Observer Pattern in C++14

I have written a small class for implementing the observer pattern in C++(14). I would welcome any comments, corrections criticisms and suggestions. Observable.h: ...
bone's user avatar
  • 191
5 votes
1 answer
140 views

Scheduling using System.IObservable 2.0

As a follow up to this first attempt to create and use my own IObservable<T> implementation, this is version 2.0. The goal has been to correct the code where ...
user avatar
4 votes
0 answers
116 views

Scheduler built with observables v3 (follow-up) - now testable

This is a 2nd follow-up to my previous one about a Scheduler built with observables. Although the last one was working correctly, it was only possible to see this ...
t3chb0t's user avatar
  • 44.1k
4 votes
1 answer
159 views

Scheduling using System.IObservable

With great inspiration from t3chb0ts ongoing work about scheduling, cron jobs etc. (last post here), I decided to make my own version of the Scheduler - using the observer pattern - as a learning ...
user avatar
4 votes
2 answers
7k views

java.util.Observable but with generics to avoid casts

This is an Observable class similar to java.util.Observable. The difference is that it uses generics to avoid casts. The ...
hkoosha's user avatar
  • 153
2 votes
1 answer
143 views

Class simulating a connection among two pins

Following this post and the one before that, here I am asking for a review on another piece of code: the connection among two pins. As usual, be merciless in your review. Here it goes: ...
Gentian Kasa's user avatar
  • 2,046
0 votes
1 answer
344 views

Does Java need an Observable object with generics?

This is the follow-up question from here. This is an Observable class similar to java.util.Observable. The difference is that ...
hkoosha's user avatar
  • 153