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

Show Posts

* | |

  Show Posts
Pages: 1 2 [3] 4 5
31  PureMVC Manifold / Multicore Version / Re: Port to AsyncCommand - A PureMVC / JS Utility on: October 01, 2014, 10:26:13
Hi Cliff:

As a test I tried to extend the AsyncMacroCommand Pattern to accommodate adding other AsyncMacroCommands, just like MacroCommand could not only execute SimpleCommands but other MacroCommands as well.

I edited single line in my own local copy to make it work inside AsyncMacroCommand.prototype.nextCommand

var isAsync = commandInstance instanceof puremvc.asynccommand.AsyncCommand || commandInstance instanceof puremvc.asynccommand.AsyncMacroCommand;

It works fine, UberAsyncMacroCommand executes FirstAsyncMacroCommand which executes all of it's sub AsyncCommands in sequence (asynchronously) and then turns to SecondAsyncMacroCommand executing it's series of AsyncCommands (asynchronously) and finally UberAsyncMacroCommand onComplete.

The exception that individual AsyncMacroCommands' onComplete functions are taken over by the Uber AsyncMacroCommand, i.e. no custom onCompleteHandlers for each subAsyncMacroCommands.

any thoughts on this on? or even should we have individual custom onComplete handlers for each subAsyncMacroCommands?
32  PureMVC Manifold / Multicore Version / Re: Event dispatching from view components on: September 29, 2014, 10:07:35
You may use Delegation Pattern without getting into event dispatching, 3rd party libraries or cross browser issues.

Example:
https://github.com/sshams/puremvc-js-demo-lockabledoor/blob/master/js/view/ApplicationMediator.js
https://github.com/sshams/puremvc-js-demo-lockabledoor/blob/master/js/LockableDoor.js

Discussed this in here as well. http://forums.puremvc.org/index.php?topic=2107.0
33  PureMVC Manifold / Multicore Version / AsyncProxy - A PureMVC / JS Utility on: September 29, 2014, 09:56:11
Based on a need to handle a series of asynchronous WebSQL or AJAX operations. Ultimate use in conjunction with AsyncCommands/AsyncMacroCommands in a sequence. Demo included.

AsyncProxy Utility
https://github.com/sshams/puremvc-js-util-asyncproxy

Demo Async Sequential
https://github.com/sshams/puremvc-js-demo-async-sequential
34  PureMVC Manifold / Multicore Version / Port to AsyncCommand - A PureMVC / JS Utility on: September 26, 2014, 03:55:37
Developed JavaScript Utility for Asynchronous Commands with a demo.

Async Command
https://github.com/sshams/puremvc-js-util-asynccommand

Demo Sequential
https://github.com/sshams/puremvc-js-demo-sequential
35  PureMVC Manifold / Port to JavaScript / State Machine Utility (using native prototype property) with LockableDoor Demo on: September 26, 2014, 12:24:27
StateMachine Utility (developed using native JavaScript Object.prototype property)
https://github.com/sshams/puremvc-js-util-statemachine

LockableDoor Demo
https://github.com/sshams/puremvc-js-demo-lockabledoor

The Demo also demonstrated a simple solution for communication between component and a Mediator that PureMVC JS community has been struggling with or have questions about, it's a Delegation Pattern in JavaScript using closures for communication between viewComponent and it's Mediator. Inspired by Objective-C Demo where the viewComponents communicates to it's Mediator via a Delegate. Have a look at the following.

https://github.com/sshams/puremvc-js-demo-lockabledoor/blob/master/js/view/ApplicationMediator.js
https://github.com/sshams/puremvc-js-demo-lockabledoor/blob/master/js/LockableDoor.js

Inside onRegister a closure was defined and is passed to the viewComponent, viewComponent only knows about functions within that closure and has no information about it's Mediator hence it's loosely coupled, that closure has reference to Mediator that can then call function of the Mediator. Closures are big and powerful in JavaScript and solved many problems.

This approach eliminates the need of any 3rd party utilities/libraries for dispatching events or Signals, you're free to use any for their benefits but my intent was to develop the demo in it's purest form and without depending upon any library, and just utilizing the power of the language and the PureMVC framework itself.
36  Announcements and General Discussion / Architecture / Multicore PureMVC with Routing on: September 23, 2014, 12:51:50
This question is in context of a JavaScript Application where angular has been employed for routing and to watch for hash changes in a browser.

Should we implement multiple routing for each submodule or implement single routing system. I'm facing some challenges with multiple routing but I see some pro's and cons for each.

A
Each submodule listen for it's own set of hash changes and acts accordingly (Added benefit is that it let's you specify it's own function calls within it's "scope" and automatic execution on hash changes, Independence etc.)

or B
Shell implements the routing system and broadcast changes via junction to all of it's submodules. Submodules listens to Routing notifications and steward viewComponents to different states or execute commands etc.

Personally I see the implementation B best though I'd lose some benefits of integrated angular benefits but I had a different case as well in a PHP implementation. A specific submodule was loaded based on the first part of the route, and then the submodule branches off and decides the operation based on the 2nd part. I was looking at my current project in the same context.

In SOAMusicPlayer, I've noticed the Browser Mediator and then it seems Shell acts on it independently without requiring submodules to do anything, but in a situation where submodules need to act as well, what's the best way to achieve from the above?

In some earlier implementations of AS3 with SWFAddress that I've seen, the routing was implemented in a proxy implying it as a data/information and in the case of SOAMusicPlayer it's a viewComponent managed by BrowserMediator. Please also expand on this.
37  PureMVC Manifold / Multicore Version / equivalent of initializeModel and initializeView in ApplicationFacade on: February 13, 2014, 02:20:40
is there an equivalent of initializeModel and initializeView in ApplicationFacade for the JS port? (http://puremvc.org/pages/docs/AS3/standard/framework_asdoc/org/puremvc/as3/patterns/facade/Facade.html)

I see a startup function in the demo examples that registers the commands and then fires the notification instead of initializeController?

https://github.com/PureMVC/puremvc-js-demo-reversetext/blob/master/src/ApplicationFacade.js

how this works out in the JS port?
38  Announcements and General Discussion / Architecture / Re: Asynchronious Loading on: January 28, 2014, 09:18:38
this would be an ideal in case proxies are dependent, i.e. one proxy determining/calculating the input for the next, and the second one for the third one and so on (for example proxies handling parent child database tables passing foreign keys to subproxies - in context of PHP Port)

and yes if there's no sort of dependency then it's better to keep them separate and at the end if there's some kind of logical checks to determine what proxies to register, command is the place to go. :-)
39  Announcements and General Discussion / Architecture / Re: Intercore Communication back and forth using Pipes on: January 27, 2014, 04:05:51
Some progress but running into a confusion/problem for this bidirectional communication between two SubModules. I need two submodules to talk each other bidirectionally (no communication to shell necessary). Was able to get it working with an implicit STDSOC (EntitlementModule to SocialModule) but EntitlementModule maybe connected to more modules.

Question: how can I get a module's STDOUT to work as a broadcast to other multiple modules it maybe connected to

P.S. The code is in PHP but you may suggest using AS3.

Shell (StartupCommand)
                     
:
require_once ('modules/social/Social.php');
require_once ('shell/view/mediators/EntitlementMediator.php');
$social = new \modules\social\Social();
$this->facade()->registerMediator(new EntitlementMediator());
$this->facade()->sendNotification(ApplicationFacade::CONNECT_MODULE_TO_ENTITLEMENT, $social);

EntitlementMediator

:
public function handleNotification(\INotification $notification) {
switch($notification->getName()) {
case ApplicationFacade::CONNECT_MODULE_TO_ENTITLEMENT:
$module = $notification->getBody();
$pipe = new \Pipe();
$module->acceptOutputPipe(PipeAwareModule::STDENT, $pipe);
$this->viewComponent->acceptInputPipe(PipeAwareModule::STDIN, $pipe);

$pipe = new \Pipe();
$module->acceptInputPipe(PipeAwareModule::STDIN, $pipe);
$this->viewComponent->acceptOutputPipe(PipeAwareModule::STDSOC, $pipe);//work
//$this->viewComponent->acceptOutputPipe(PipeAwareModule::STDOUT, $pipe);
//how can I get STDOUT to work as a broadcast to all modules it maybe connected to
break;
}
}

EntitlementJunctionMediator

:
public function handleNotification(\INotification $notification) {
switch($notification->getName()) {
case \JunctionMediator::ACCEPT_INPUT_PIPE:
if($notification->getType() == PipeAwareModule::STDIN) {
$pipe = $notification->getBody();
$teeMerge = $this->junction->retrievePipe(PipeAwareModule::STDIN);
$teeMerge->connectInput($pipe);
} else {
parent::handleNotification($notification);
}
break;

default:
parent::handleNotification($notification);
break;
}
}

public function handlePipeMessage(\IPipeMessage $message) {
echo " entitlement ";
$this->junction->sendMessage(PipeAwareModule::STDSOC, new \Message("note name", null, "body"));
}


SocialJunctionMediator

:
public function handleNotification(\INotification $notification) {
switch($notification->getName()) {
case \JunctionMediator::ACCEPT_INPUT_PIPE:
if($notification->getType() == PipeAwareModule::STDIN) {
$pipe = $notification->getBody();
$teeMerge = $this->junction->retrievePipe(PipeAwareModule::STDIN);
$teeMerge->connectInput($pipe);
} else {
parent::handleNotification($notification);
}
break;

default:
parent::handleNotification($notification);
break;
}
}

public function handlePipeMessage(\IPipeMessage $message) {
echo "social";
}

40  Announcements and General Discussion / Architecture / Re: Asynchronious Loading on: January 27, 2014, 09:31:50
how about your Proxies registering other proxies in their onRegister function or within their onComplete (if web services are involved) in a chain...
41  Announcements and General Discussion / Architecture / Bidirectional Communication between Modules using Pipes on: January 26, 2014, 12:50:05
I went couple of posts under "Architecture" forum that are talking about intercore communication but I think I need more help.

I've two submodules talking to each other, let's say a login module and a social module (plus others).

For some internal reasons, the login module is separate because of it's complexity and kind of services it's paired with.

If social module is invoked/requested, it needs to first pass the authToken (encrypted username/password) to "Login" module (Login and Social modules are connected to each other via Pipes).

Login module in turn returns true (with user data) or false, and then Social can carry on forward with what it has to do.

I understand that Pipes is one-way communication but I need communication back and forth. There are no web services involved, so it's not an asynchronous call. I'm using PHP port, it checks the database synchronously and returns true (with user data) or false.

What i can think is of is that, send a message with authToken from SocialJunction to LoginJunction and LoginJunction retrieves the Proxy, calls the function, gets it result and sends a message in return, received by SocialJunction and it carries on forward from there? Please advise.

Future Needs: (if multiple types of communication back and forth, use type attribute to distinguish between type of calls, Yes???)

Also if Asynchronous calls, can you pass a function of one submodule and have it executed by the second module as discussed here under Shared Proxies. http://forums.puremvc.org/index.php?topic=2080.0
Is that what async token pattern is or what is it?

Appreciate your help.
42  PureMVC Manifold / Standard Version / Objective-C Multicore version & Pipes Utility on: December 06, 2013, 10:29:40
Any plans or ongoing work for this? Looking forward to it.
43  PureMVC Manifold / Standard Version / Re: feature request on: December 06, 2013, 10:16:50
you're right, but following approach is helpful (from visibility point of view) and reduces lines of code when I've several proxy or mediator instantiations going on in one place.

this.testProxy = this.facade.registerProxy(new TestProxy());
instead of another short form (this.facade.registerProxy(this.testProxy = new TestProxy());
... plus several more proxies or mediator instantiations.
44  PureMVC Manifold / Standard Version / feature request on: September 27, 2013, 11:12:11
Hi Cliff:

Possible that if you can implement a change across all the ports in your next release, that the registerProxy function returns the proxy after calling onRegister function. Same with registerMediator, that it should return the registered mediator.

I run into a case where I had to register sub-proxies and sub-mediators inside proxies and mediators (onRegister function) and had to write additional lines to retrieve them.

I added return at the end for Facade, Model and View for registerProxy and registerMediator functions for this PHP port and wish that if it becomes part of all other ports. Any thoughts?

Regards.
45  Announcements and General Discussion / Architecture / Data Request from Components on: June 13, 2012, 12:40:29
I'm not sure, I read an example somewhere for a best strategy to implement.

For instance,

1) a component needs some data at user request (click of a button), event is dispatched.
2) Mediator in the listener function retrieves the proxy and calls the function on it.
3) Proxy makes the data request and has a handler method for the response.
4) Proxy then sends the notification once data is ready inside handler method
5) Notification is received by the same Mediator in this case, and populates the component.

For me it seems like a long trip, is there a shorter way?
Pages: 1 2 [3] 4 5