Questions tagged [observers]

An object which registers itself to listen for updates on another object

In an , observers register themselves with a subject. The subject notifies each of its observers about updates to itself, usually by calling a method on the observers.

911 questions
11
votes
3 answers

Some fragment observers trigger after pop from back stack although data is not changed

I have some problem in nested fragment in Kotlin. I have nested fragment with ViewModel. After resuming fragment from back button press all observers on viewModel LiveData triggers again although my data does not changed. First i googled and tried…
Mahdi
  • 6,139
  • 9
  • 57
  • 109
11
votes
3 answers

How to change parameter in Observable (RxJs)

I use HTTP provider in Angular 2 for data loading from API. return this.http.post(url, urlSearchParams.toString(), { headers: this.getHttpHeaders() }) .retryWhen((error) => { return this.handleRetryError(error); }) When…
Lumix
  • 111
  • 4
11
votes
2 answers

iOS Testing: dispatch_once get called twice. First in App, second in Test. Problems with Observers

I have a singelton class which will be create in the app delegate. When i run XCTTests then its get create a second time. + (instancetype)urlSchemeManager { static dispatch_once_t onceToken; static UrlSchemeManager* _sharedInstance; …
Sam
  • 2,707
  • 1
  • 23
  • 32
10
votes
2 answers

Observable/Observer not working?

I tried implementing a static Observable in my Application subclass, but it's not working. No exceptions or error messages, but my update() callback doesn't get called. MyApplication.java public class MyApplication extends Application{ public…
Magnus
  • 17,157
  • 19
  • 104
  • 189
9
votes
1 answer

Prevent action from Laravel observer events

I would like to know how an action could be prevented on a model observer, for example: $model->update(['foo' => 'bar']); In the observer public function updating(Model $model) { if($model->isDirty('foo') { // Prevent action from…
Asur
  • 3,727
  • 1
  • 26
  • 34
9
votes
3 answers

Laravel observer for pivot table

I've got a observer that has a update method: ObserverServiceProvider.php public function boot() { Relation::observe(RelationObserver::class); } RelationObserver.php public function updated(Relation $relation) { …
Jamie
  • 10,302
  • 32
  • 103
  • 186
9
votes
2 answers

How to create Selector with parameters from string

I am writing a program using Swift 3.1 and Xcode 8.3.3. I want to create a class, responsible for moving entire view when keyboard appears and disappears. But I faced difficulties with creating custom Selector with parameters from string. To show or…
Alex
  • 1,038
  • 2
  • 12
  • 32
9
votes
2 answers

Are DOM Mutation Observers slower than DOM Mutation Events?

The following code utilize DOM Mutation Event DOMNodeInserted to detect the existence of the body element and wrap its innerHTML into a wrapper.
Ian Y.
  • 2,293
  • 6
  • 39
  • 55
8
votes
2 answers

Using weak_ptr to implement the Observer pattern

What I have so far is: Observer.h class Observer { public: ~Observer(); virtual void Notify() = 0; protected: Observer(); }; class Observable { public: ~Observable(); void Subscribe( std::shared_ptr observer ); …
ophilbinbriscoe
  • 137
  • 1
  • 8
8
votes
1 answer

Is there a way to get didSet to work when changing a property in a class?

I have a class as property with a property observer. If I change something in that class, is there a way to trigger didSet as shown in the example: class Foo { var items = [1,2,3,4,5] var number: Int = 0 { didSet { items…
Henny Lee
  • 2,970
  • 3
  • 20
  • 37
8
votes
1 answer

How to observe an array of NSObjects in swift?

I am new in swift language and my problem is about how to use observable/observer pattern in swift. I want to make my array to be observable in my SocketManager class so it can be observed by my UIViewController class. I have used the Observable…
user2366997
  • 91
  • 1
  • 7
8
votes
1 answer

ember js component observer does not work

I have a scenario in emberjs component where the observe does not get hit. I figured out the reason as "the component is not yet inserted when the component property being observed is set." My questions is, couldn this be handled in a better way in…
wallop
  • 2,510
  • 1
  • 22
  • 39
7
votes
1 answer

LiveData observer fired twice, even with viewLifecycleOwner

I'm struggling with a LiveData observer which is firing twice. In my fragment I'm observing a LiveData as below, using viewLifeCycleOwner as LifeCycleOwner private lateinit var retailViewModel: RetailsViewModel override fun…
7
votes
1 answer

Apply custom promo rule using observer in Magento 2

I have created new table in Magento 2, for storing custom promorules, now I have created observer for event controller_action_predispatch_checkout_cart_couponPost and inside that observer I want to check if user has entered any custom rule then…
Dhara Parmar
  • 8,021
  • 1
  • 16
  • 27
7
votes
1 answer

What's the right magento observer event to capture order paid?

I'm trying to send orders to a third-party after and ONLY after an order has been paid and has now been set to 'Processing' as status. What's the best observer to use to set up this to work for all payments types? After reading several sources it…
Ox3
  • 451
  • 1
  • 6
  • 22
1
2
3
60 61