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]
1  Announcements and General Discussion / Architecture / Need some State Machine advice on: May 09, 2013, 03:23:47
Background:
I am using Haxe PureMVC with State Machine to build a web application (deployed to JavaScript). I am integrating it with a government-mandated UI framework that uses a JQuery-powered tabbed interface. The application has 4 tabs and I have created an application state for each of these tabs. The tab interface (EasyTabs) has a built-in event system which helps the integration. Clicking a tab fires an event, and if the handler for the event (in my Haxe app) returns true, only then will the tab view change.

Problem:
I want that handler to send a StateMachine.CHANGE notification and let the "Entering" command for the next tab state to do the necessary checks that ultimately cancel or approve the state transition. I'm just not sure how to send the notification and use the results of that action to return true or false so that EasyTabs gets the Boolean it requires.

Here's my current code:
:
var tabs=new JQuery("#theTabs");
tabs.bind("easytabs:before",tabHooksHandler); //setup the handler for the tab event

private function tabHooksHandler(e:Dynamic,clicked:Dynamic,targetPanel:Dynamic,settings:Dynamic):Bool{
switch(targetPanel.selector){
case"#tab1":
                    sendNotification ( StateMachine.ACTION, null, Main.ACTION_GOTO_FILE );
case"#tab2":
                    sendNotification ( StateMachine.ACTION, null, Main.ACTION_GOTO_TREES );
case"#tab3":
                    sendNotification ( StateMachine.ACTION, null, Main.ACTION_GOTO_MAP );
case"#tab4":
                    sendNotification ( StateMachine.ACTION, null, Main.ACTION_GOTO_CALCULATOR );
}
return true; //this lets EasyTabs complete the switch of tabs. If the StateMachine does a cancel, I would want this to return false.
}
So, could I use a callback somehow? Suggestions would be appreciated, thanks!
Pages: [1]