Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Different cores or modules using a common data source  (Read 13957 times)
onedotover
Newbie
*
Posts: 1


View Profile Email
« on: November 25, 2009, 10:26:21 »

I'm building an Air application with multiple pages/sections. For simplicity, let's just focus on two of the sections: Contacts and Events. The contacts "page" will have a list of contacts that, when clicked, pulls into a detail view for that contact. The detail view has a list of events that contact is going to and a todo list for that person. The events page will work in the same way, but with a list of contacts attending and a todo list for the event.

To me, it seems like each page should have it's own core given their complexity and so I can develop them separately or so I can have another developer create the events page while I create the contacts page. I'm having trouble figuring out how to orchestrate this. All of the content has to be pulled from a common database and each of the pages needs info that is specific to the other page.

It doesn't make sense for the contacts page to have an "events proxy" that gets a list of events and for the events page to have essentially a duplicate proxy with the same functions. This is where I'm getting stuck:

1. Should they all be able to access common proxies within the ShellFacade to interact with the database? So the contacts page can pull info from the events proxy (notifications)?

2. I'd rather keep all events logic within the events page and somehow communicate between the two. For example, the contacts page could ask the events page for a list of events. But this feels like they are too tightly coupled.

3. I'll need to be able to add another page down the road that pulls from info from either section as well.

Any direction is much appreciated!
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: November 25, 2009, 01:01:46 »

Modular programming allows a whole new level of code separation, but the most important separation to make remains the Model.

Try putting your service handling into one core, your contacts stuff into a second and your events stuff into a third.

Then have the shell plumb them all in such a way that the contacts core and the events core both have bidirectional pipes connecting them to the service core. Then they can all communicate via pipe messages for interacting with the service core. And you may want bidirectional pipes between the event and contact cores, so that, for instance, if you select a contact in the contact core, you send the event core a message telling it to display the events for the selected contact.

Which means you'll want a protocol for communicating with the service core such as:

RETRIEVE_CONTACT -> CONTACT_RETRIEVED
UPDATE_CONTACT -> CONTACT_UPDATED
SHOW_EVENTS_FOR_CONTACT -> CONTACT_EVENTS_DISPLAYED

etc.

These will be expressed as custom pipe messages being exchanged between the cores. Those custom pipe messages probably carry typed objects, such as a contact, event, or a list of contacts or events.

So, put the data into value objects and custom pipe messages that are defined in a common package that the contacts, events and service cores all share.

-=Cliff>
Logged
dihardja
Jr. Member
**
Posts: 17


View Profile Email
« Reply #2 on: December 02, 2009, 07:01:54 »

Hi,

does anyone has experienced a workaround while having a "service" core and submitting a HTTP post request which requires the user initiated action of the flash player 10?

For example, recently in a flash project, i had to make a post request which contains generated png images. since this post request can only be executed inside the click listener function stack, i couldn't place it inside my "service" core.


thanks



Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: December 02, 2009, 08:45:39 »

The call stack should extend all the way through from the ui component in the core with the view to the proxy in the core that makes the request. The services I'm working with at the moment are all RemoteObjects, so I'll need to try and mock something up.

Did you get an exception?
-=Cliff>
Logged
dihardja
Jr. Member
**
Posts: 17


View Profile Email
« Reply #4 on: December 03, 2009, 02:20:10 »

Yes, i got an exception. Honestly. I don't know how to extend the stack of the listener function. I had the listener function inside a mediator which sends a message with a vo to the service core. The service core then executes a command for this. The message for the service core is sent from inside the listener function, therefore i thought that the request should be inside the same stack but still i got the exception.



   



« Last Edit: December 03, 2009, 02:38:10 by dihardja » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #5 on: December 03, 2009, 10:39:52 »

Can you post the text of the exception please?

-=Cliff>
Logged
dihardja
Jr. Member
**
Posts: 17


View Profile Email
« Reply #6 on: December 07, 2009, 10:19:58 »

Hi,

sorry for the delayed reply. the project is actually not an actual one, but the exception I got when I try to submit the post http request from the service core instead directly from the listener function is:

Error: Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.

 
Logged
omar
Newbie
*
Posts: 9


View Profile Email
« Reply #7 on: December 07, 2009, 06:19:56 »

Are you doing something else beside trying an HTTP POST?

I have an application I'm developing that handles the POST in a similar set up.  That error you posted is the error that was added to some actions that are prevented if not directly from a mouse click, like going to full screen mode.  You can't just force someone into full screen anymore if it doesn't come from a mouse click event. 
Logged
dihardja
Jr. Member
**
Posts: 17


View Profile Email
« Reply #8 on: December 08, 2009, 10:04:18 »

Yes, of course. the http POST request requires the user initiated action.

My question above wasn't why i got the exception or what the exception means.
I was wondering if someone has succesfully, or has some idea how to, submit an http post which requires an user initiated action from another core than where the click listener function is.
« Last Edit: December 08, 2009, 10:12:16 by dihardja » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #9 on: December 08, 2009, 02:26:24 »

I'm looking into this. Meanwhile, I wonder if your service module is being loaded into the application domain?

-=Cliff>
Logged
dihardja
Jr. Member
**
Posts: 17


View Profile Email
« Reply #10 on: December 11, 2009, 02:10:11 »

Yes, the service module is created within the shell
Logged
amahi
Newbie
*
Posts: 4


View Profile Email
« Reply #11 on: December 11, 2009, 08:36:59 »


Which means you'll want a protocol for communicating with the service core such as:

RETRIEVE_CONTACT -> CONTACT_RETRIEVED
UPDATE_CONTACT -> CONTACT_UPDATED
SHOW_EVENTS_FOR_CONTACT -> CONTACT_EVENTS_DISPLAYED


Hi
That will be ok for a little application, but for a bigger application, identify all the case can be very long and not really interesting.
Can we put a single protocal like:
ASK_PROXY -> DATA_READY

The component mediator send a notification like that:
sendNotification(ASK_PROXY, data, RETRIEVE_CONTACT)
The junction Mediator send Message to service core
The service core respond in the same way.

That will work if you don't need notification type.

(Est ce que cela fonctionnerait comme ├ža?)
Does this work like that ?

Sorry for my english !



Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #12 on: December 11, 2009, 12:38:44 »

@dihardja: Are you saying the module is instantiated in the shell or is it loaded? There is a difference. If you're loading it you need to load it into the same ApplicationDomain. It should look something like this:

:
        protected function loadModule( resourcePath:String) : void
        {
                var info:IModuleInfo = ModuleManager.getModule( resourcePath );
                if ( ! info.loaded )
                {
                        info.addEventListener( ModuleEvent.READY, handleModuleLoaded );
                        info.addEventListener( ModuleEvent.ERROR, handleModuleLoadFailed );
                        info.load( ApplicationDomain.currentDomain );
                }
        }

@amahi Sure you can make a protocol like that, but you're just pushing the constant into the type property of the notification you're sending to the junction mediator. I advocate building a protocol of specific message subjects because you can filter on that if you're using pipes. And debugging, looking at the message will make more sense if it's semantic.

-=Cliff>
Logged
Pages: [1]
Print