Dofactory.com
Dofactory.com
 Back to list
Views:   15.1K
Replies:  3
Archived

Where to place events from service layer in MVP?

I am coding a GUI that communicates via TCP/IP with Automated Guided Vehicles (AGVs).

The Model communicates with TCP/IP Service layer.
I was thinking of letting the Presenter subscribe to the TCP/IP events?

But is this the best solution?
After receiving the events the View should be updated.

Any suggestions are appreciated.
Elund Christensen, Jul 18, 2010
Reply 1
My solution for the time being:

The Model creates an instance of TCP/IP Service and calls the TCP/IP Service layer.

The different Presenters subscribes to relevant TCP/IP events and updates the View.

To avoid passing of functions (or other problems) I have implemented the TCP/IP Service as a Singleton.

I anyone knows of good examples/articles on how to handle events from a non Microsoft service layer in MVP,
please post a link here.
Elund Christensen, Jul 21, 2010
This is the best answer I ever read!
Oct 24, 2011
Reply 2
Joshua, thanks for your answer :-)
I think my problem is that I have 2 Presenters.
I want both Presenters to subscribe to the TCP/IP events.
The instance of TCP/IP Service layer is created in the Model.
Do I have to pass the functions that should be called in the 2 Presenters to the Model?
Or maybe I should create the TCP/IP Service layer in the base class for all Presenter classes
and then pass it to the Model?
Elund Christensen, Jul 19, 2010
Reply 3
You can probably use a repository pattern/layer to abstract out that service layer calls... and call it within the presenter.

You can use Action<T>/Func<T>/Predicate<T> delegates to subscribe to the events and handle it in the presenter.

just my two cents
Joshua Sim, Jul 19, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.