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]
Author Topic: Handling data added by user  (Read 7064 times)
Jr. Member
Posts: 14

View Profile WWW Email
« on: March 05, 2008, 11:19:02 »

I have an AIR app where the user can drag and drop images from their desktop to a TileList. My current debate is where to put the logic to sort through all this data. For example, once the images are dropped on the TileList I verify that each file is of an accepted type (jpg, gif, etc), then I need to update the model (the dataProvider to the TileList).
Would you recommend doing this logic in the TileList itself, then notifying the Proxy, which would in turn update the Model? That doesn't make too much sense to me, b/c at that point I would feel like the Mediator should just update the Model directly.
Otherwise, within the View I could add all the files to an Array, then notify the Mediator which could then sort through the Array and do the verification, then update the Model.
The latter seems to make more sense but I wanted to get another opinion, and also make sure I'm not overlooking something.
Global Moderator
Hero Member
Posts: 2871

View Profile WWW Email
« Reply #1 on: March 05, 2008, 12:01:17 »

Hi Mac,

You're headed in the right direction here. Don't introduce any dependencies on Proxies (or any PureMVC related actors) inside your view components. VOs are a different thing, because they are just data carriers.

However, we also don't want our mediators to become very complicated. This is business logic.  And the proper home for that is a Command.

So I see something like this happening:

Custom component containing (or extending) TileList (MyTileList) responds to the drop by placing the incoming data in a public variable like 'droppedMedia:ArrayCollection' (or whatever).

MyTileList dispatches an event like 'MyTileList.MEDIA_DROPPED' whose MyTileListMediator hears it, and simply sends a Notification like 'ApplicationFacade.HANDLE_DROPPED_MEDIA'. It includes myTileList.droppedMedia as the Notification body.

This is handled by the previously registered HandleDroppedMediaCommand, who sifts, sorts, validates, and updates the appropriate Proxy(s).

« Last Edit: March 05, 2008, 12:07:24 by puremvc » Logged
Pages: [1]