Rx for .NET – What happened to Scheduler.Dispatcher?
The DispatcherScheduler has been moved to the System.Reactive.Windows.Threading assembly. If you are using NuGet, it’s in Rx-WPF
The DispatcherScheduler has been moved to the System.Reactive.Windows.Threading assembly. If you are using NuGet, it’s in Rx-WPF
Ah. You’re observing a TekkPoint object from a SomethingElse object, and the SomethingElse object is the one adding and removing the observers, correct? (That’s the normal way things are done; I’m just trying to clarify.) It looks like your TekkPoint object is being deallocated while the SomethingElse that’s observing it is still around. The SomethingElse … Read more
Very interesting issue. Try this: Change remObserver to null out the entry, rather than just removing it (and invalidating the list iterators). Change your notifyAll loop to be: for (all registered observers) { if (observer) observer->notify(); } Add another loop at the end of notifyAll to remove all null entries from your observer list
I think that bind makes it easier to create slots (cfr. the ‘preferred’ syntax vs. the ‘portable’ syntax – that’s all going away). The observer management, however, is not becoming less complex. But as @R. Martinho Fernandes mentions: an std::vector<std::function< r(a1) > > is now easily created without the hassle for an (artificial) ‘pure virtual’ … Read more
Any defined function can be passed by simply using its name, without adding the () on the end that you would use to invoke it: def my_callback_func(event): # do stuff o = Observable() o.subscribe(my_callback_func) Other example usages: class CallbackHandler(object): @staticmethod def static_handler(event): # do stuff def instance_handler(self, event): # do stuff o = Observable() # … Read more
One really important distinction to keep in mind, which is related to Milan Novota’s answer, is that callbacks on an ActiveRecord have the ability to cancel the action being called and all subsequent callbacks, where as observers do not. class Model < ActiveRecord::Base before_update :disallow_bob def disallow_bob return false if model.name == “bob” end end … Read more
Citing Li Haoyi, who has used Scala.React, his observations are: “it is extremely difficult to set up and get started.” “It requires a fair amount of global configuration” “It took several days to get a basic dataflow graph (..,) working.” He had a lot of questions but did not manage to contact the author of … Read more
Nothing is magic in the life : if you update a value, your Observable won’t be notified. You have to do it by yourself. For example using a PublishSubject. public class Test extends MyChildActivity { private int VARIABLE_TO_OBSERVE = 0; Subject<Integer> mObservable = PublishSubject.create(); protected void onCreate() {/*onCreate method*/ super(); setContentView(); method(); changeVariable(); } public … Read more
You are on the right track, but I have run into a number of frustrating unexpected message errors when using rSpec, observers, and mock objects. When I am spec testing my model, I don’t want to have to handle observer behavior in my message expectations. In your example, there isn’t a really good way to … Read more
The Observer pattern, depending on implementation choices, may pose an ownership challenge. In garbage collected languages it is typical to have the Observable referring to the Observer (to notify it) and the Observer referring to the Observable (to unregister itself)… this causes some challenges in terms of ownership (who outlives whom?) and there is this … Read more