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
7
votes
2 answers

Add 'addObserver' (NSNotificationCenter ) in a 1st view controller, handle in 2nd

I saw a few examples about adding observer and handle in the same class, but what I want to know is if it's possible to add observer in first view controller and handle it in second view controller? I want constantly send distance from first view…
Idan Moshe
  • 1,675
  • 4
  • 28
  • 65
7
votes
6 answers

Good idea to access session in observer or not?

I want to log user's actions in my Ruby on Rails application. So far, I have a model observer that inserts logs to the database after updates and creates. In order to store which user performed the action that was logged, I require access to the…
Jaryl
  • 2,561
  • 1
  • 24
  • 33
6
votes
2 answers

Trouble using swift 4's KVO "observe" instead of addObserver

I'm having some trouble getting the new KVO syntax right. According to the Apple documentation: Create an observer for the key path and call the observe(_:options:changeHandler) method. For more information on key paths, see Keys and Key…
Eden
  • 1,782
  • 15
  • 23
6
votes
5 answers

RxJS: Treat first case specially, but continue streaming the rest

Say I wanted to separately handle the first event emitted by an Observable, but then continue my subscription. For example, if I had the following chain: observable.throttleTime(2000) .takeFirst(() => console.log('potato')) …
Abraham P
  • 15,029
  • 13
  • 58
  • 126
6
votes
1 answer

Android FileObserver example in Xamarin/C#?

I need guidance in creating a file observer in Xamarin c# (Android) Some sort of workable example would be wonderful ! I've tried to convert the java ones over to C# but due to my lack on experience in the C# environment, it's throwing too many…
R3b0oT
  • 110
  • 1
  • 8
6
votes
3 answers

Using after_commit only on create

I have a UserObserver with after_commit (changed from after_create to avoid a race condition error that id not found) to update the count. But I know for every create, update is executing the after_commit code (which I knew would happen). How can I…
Milind
  • 4,535
  • 2
  • 26
  • 58
6
votes
2 answers

Obversing route change to apply equivalent to onload

I'm trying to observe the route change to apply some common action once rendered. The idea is to have a feature similar to the onload but as we use a single-page app this needs to be triggered on each route changes. (could be scoped to the new…
6
votes
3 answers

C++ Own Observer Pattern

I'm designing an observer pattern which should work this way: observer calls AddEventListener method of EventDispatcher and passes a string which is the name of the event, PointerToItself and a PointerToItsMemberMethod After that event happens…
Kolyunya
  • 5,973
  • 7
  • 46
  • 81
6
votes
1 answer

How to update content of one ArrayController from the selected value of another ArrayController in Ember.js

I have the following problem in ember.js. A child controller depends on a selected value in a parent controller in order to determine its content. In the database a child has a parent_id reference. App.parentsController =…
codehugger
  • 629
  • 5
  • 16
5
votes
1 answer

Why does “Bluetooth Low Energy primer” document state that a BLE observer device needs a transmitter and may or may not have a receiver?

I was reading the Bluetooth LE primer document and stumbled across the table given below: My doubt is how can receiver be optional if the observer's only job is to receive BLE data and not transmit any thing back. Should it not be the other way?…
5
votes
1 answer

How to check initially if an element is intersecting using IntersectionObserver

Goal: I want to perform one action for a group of elements which are intersecting on page load and handle all others(which are currently not intersecting) individually. Issue: Every observer has its own callback and I can't get result for a group of…
Antoan Elenkov
  • 711
  • 1
  • 5
  • 20
5
votes
1 answer

Handle To Remove/Add Live Data Observer to Observe On Button Click

I want to to observe a row in room database. it change after some period. but when we stop button click it need to be stop observing form database and when click start button it start observing again. My current code is To create Observer …
5
votes
4 answers

Vue - how to recognize [__ob__: Observer]?

In my component I loop through a data property, which is an object, to check whether any values are set. One of the values is an array, but when it's empty and I console log its value it returns [__ob__: Observer]. If I test if it's an array or…
Galivan
  • 4,842
  • 9
  • 44
  • 76
5
votes
3 answers

Using Request within Eloquent Model Observer

In Laravel 5.3, we're trying to create a form, which the user can update their profile details, including a new password. However we want to only set the password if its been submitted. We're using a CRUD framework which handles the updating of the…
owenmelbz
  • 6,180
  • 16
  • 63
  • 113
5
votes
2 answers

Polymer 1.0 observers - not working on array

I set an observer on to catch all polymer recognized events on an property that is an array, but I catch get it to catch the change. In my example below my observer function "bigup" only gets called on when the property, "bigs" is first…
Gilberg
  • 2,514
  • 4
  • 31
  • 41
1 2
3
60 61