observer-pattern

Trigger update for a LiveData member when another LiveData is updated in the view model

南楼画角 提交于 2020-01-06 02:29:30
问题 In a word game app I share a model between an activity and a fragment: public class MainViewModel extends AndroidViewModel { private LiveData<List<Game>> mGames; private final MutableLiveData<Game> mDisplayedGame = new MutableLiveData<>(); (please excuse the non-english text in the screenshot) The activity observes mGames being currently played by the user and updates the navigational drawer menu (see the left side of the above screenshot). The fragment observes mDisplayedGame and displays it

Java - Combine Observer pattern with timer task?

不羁岁月 提交于 2020-01-04 08:06:07
问题 In a previous post, I used the observer pattern. Description - class Flight has a status (ie int) - before time, on time, late. This is my Observable class FlightStatusMonitor has an ArrayList of Flights. This class is my observer. There is only one such observer. The update(Observable o, Object arg) method will update the status of the flight and also display the refreshed flight status of all flights that it observes. I was thinking of using timer tasks to change the status of flights at

How do I listen to all Seam contextual events with parameterized names?

那年仲夏 提交于 2020-01-04 05:23:06
问题 Seam will fire different kinds of events that relate to particular scopes, tasks, or processes and appends the name of the scope, task or process to the end of the event. How do I listen to all the events of a type? E.g. for any <name> I'd like to listen to events such as these: org.jboss.seam.createProcess.<name> — called when the process is created org.jboss.seam.endProcess.<name> — called when the process ends org.jboss.seam.initProcess.<name> — called when the process is associated with

Implementing observer pattern with events

我与影子孤独终老i 提交于 2020-01-03 18:52:12
问题 I am working on a Silverlight application where I made excessive use of the observer pattern. In my implementation I have created two interfaces IObservable<T> and IObserver<T> . The former contains methods to attach and detach observers to the observable. The latter has a method Notify(IObservable<T> observable, ...) that is called by the observable passing itself as parameter via observer.Notify(this, ...) when the observable has changed its state. Now I have stumbled upon "events" and for

Implementing observer pattern with events

隐身守侯 提交于 2020-01-03 18:52:09
问题 I am working on a Silverlight application where I made excessive use of the observer pattern. In my implementation I have created two interfaces IObservable<T> and IObserver<T> . The former contains methods to attach and detach observers to the observable. The latter has a method Notify(IObservable<T> observable, ...) that is called by the observable passing itself as parameter via observer.Notify(this, ...) when the observable has changed its state. Now I have stumbled upon "events" and for

KVO doesn't work with keypath like com.alpha.

蓝咒 提交于 2020-01-03 03:22:07
问题 My NSMutableDictionary contains simple keys (@"one", @"two", @"three") and complex keys (@"com.alpha", @"com.beta"). Is it possible to use observers for a complex key? Observers work well with simple keys, but didn't worked with complex keys. What is a solution? [self.dict addObserver:self forKeyPath:@"com.alpha" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil]; -(IBAction) onChange:(id)sender { [self.dict setObject:@"newValue" forKey:@"com.alpha"]; } -(void)

RESTful Webservice with Jersey in Java and observer pattern

安稳与你 提交于 2020-01-02 18:42:40
问题 I'm trying to implement an n-tier architecture application for a school project. The communication between the clients and the server is done with a RESTful Webservice. I Used Jersey to implement this in Java . The only question I have is, how to register the clients at the server to receive notification of changes (like normally done with the observer pattern or listen/publish pattern). Do i need to implement a service on the client side aswell and then register the URL to be called by the

How to download images asynchronously from web server

谁说胖子不能爱 提交于 2020-01-01 16:48:07
问题 My application screen looks similar to the image attached. I have multiple rows and each row has a Bitmap image, title and description field. All the information's are getting fetched from our supporting web-server in the form of XML. Now, I have used observer design pattern, which creates a separate thread for connecting to my remote server over HTTP, downloads and parse the XML. The XML includes the URL for image, title and description for each row. I have tried few approaches so far,

How to download images asynchronously from web server

倾然丶 夕夏残阳落幕 提交于 2020-01-01 16:48:06
问题 My application screen looks similar to the image attached. I have multiple rows and each row has a Bitmap image, title and description field. All the information's are getting fetched from our supporting web-server in the form of XML. Now, I have used observer design pattern, which creates a separate thread for connecting to my remote server over HTTP, downloads and parse the XML. The XML includes the URL for image, title and description for each row. I have tried few approaches so far,

Consuming paginated service in Angular2 & Ionic2 using Observables

守給你的承諾、 提交于 2020-01-01 07:23:36
问题 I have a remote collection of interface Foo { id: string; properties: any; } Which I can access using a class FooAPIService { find(skip = 0): Promise<Foo[]> { // promises at most 5 Foos. to get more, use skip > 1 // pagination is server side } on(event: string, callback: (foo: Foo) => any) { // registers event handler, for events: created, updated, removed // events triggered when a change occurs server side } } As a newcomer to Angular2 (and Ionic2), I'm trying to figure out how to consume