51. foomo.managers.MemoryManager
public interface IMemoryManager
{
function gc():void;
function unload(obj:Object):void;
function addUnloader(type:*, unloader:IUnloader):void;
function removeUnloader(type:*):void;
}
53. foomo.managers.LogManager
public interface ILogManager extends IEventDispatcher
{
function get level():int
function set level(value:int):void
function isDebug():Boolean
function isInfo():Boolean
function isWarn():Boolean
function isError():Boolean
function isFatal():Boolean
function removeLoggingTarget(target:*):Boolean;
function addLoggingTarget(target:ILoggingTarget):String
function log(category:*, level:int, message:String, parameters:Array):void;
}
# Set log level
LogManager.level = LogLevel.DEBUG;
# Log entry @see SparkExamples
if (LogManager.isDebug()) LogManager.debug(this, "Can't undo command - command in queue");
54. foomo.managers.SessionManager
public interface ISessionManager
{
function get localIsAvailable():Boolean
function get clientId():String
function get sessionId():String
function setLocalData(key:Object, value:*):*
function getLocalData(key:Object, defaultValue:*=null):*
function removeLocalData(key:Object):*
function flushLocal():String
function clearLocal():void
}
60. CommandManager
public interface ICommandManager extends IEventDispatcher
{
function set historyName(value:String):void
function get historyName():String
function set historySize(value:int):void
function get historySize():int
function get undoAble():Boolean
function get redoAble():Boolean
function execute(command:ICommand):void
function undo():void
function redo():void
}
# Controller
this.executeCommand(new AddTodosCommand([todo], this.model, true));
61. StatusManager
public interface IStatusManager extends IEventDispatcher
{
function get stack():Array;
function get busy():Boolean;
function setBusyStatus(instance:Object):void;
function removeBusyStatus(instance:Object):void;
}
# Anywhere
StatusManager.setBusyStatus(this);
StatusManager.removeBusyStatus(this);
63. Operations
public interface IOperation extends IEventDispatcher
{
function get result():*;
function get error():*;
}
public interface IProgressOperation extends IOperation
{
function get total():Number;
function get progress():Number;
}
74. Writing Code
Pure MVC
Command based
Operation based (OperationChain)
Operations & Commands
- no right way
- many possibilities
- take notes!
- feedback?
i.e.
- operations in model
77. Command based
public class ApplicationController extends ZugspitzeController
{
//...
public function setCurrentState(state:String):void
{
this.executeCommand(new SetValueCommand(this.model, 'currentState', state, true));
}
public function editTodo(todo:Todo):void
{
this.executeCommand(new SetValueCommand(this.model, 'todo', todo, true));
this.executeCommand(new SetValueCommand(this.model, 'currentState', ApplicationModel.STATE_EDIT,
true));
}
public function addTodo(text:String):void
{
this.executeCommand(new AddTodoCommand(text, this.model));
this.executeCommand(new SetValueCommand(this.model, 'currentState',
ApplicationModel.STATE_OPEN_LIST, true));
}
//...
}
78. Command based
public class ApplicationModel extends ZugspitzeModel
{
//...
public var todoProxy:Service1Proxy = new Service1Proxy;
public var currentState:String = STATE_LOADING;
public var opentTodos:ArrayCollection;
public var completeTodos:ArrayCollection;
public var todo:Todo;
public function setTodos(todos:Array):void
{
var open:Array = new Array;
var complete:Array = new Array;
for each (var todo:Todo in todos) {
if (todo.complete) {
complete.push(todo);
} else {
open.push(todo);
}
}
this.completeTodos = new ArrayCollection(complete);
this.opentTodos = new ArrayCollection(open);
}
//...
}
79. Command based
public class AddTodoCommand extends AbstractAddTodoCommand
{
public var model:ApplicationModel;
public function AddTodoCommand(text:String, model:ApplicationModel)
{
this.model = model;
super(text, this.model.todoProxy, true);
}
override protected function methodCall_proxyMethodCallResultHandler(event:ProxyMethodCallEvent):void
{
this.model.setTodos(AddTodoCall(event.methodCall).result);
this.dispatchCommandCompleteEvent();
}
}
83. Operation based
public class ApplicationController extends ZugspitzeController
{
//...
public function setCurrentState(state:String):void
{
this.model.currentState = state;
}
public function editTodo(todo:Todo):void
{
this.model.todo = todo;
this.model.currentState = ApplicationModel.STATE_EDIT;
}
public function getTodos():void
{
OperationChain
.create(GetTodosOperation, this.model.todoProxy)
.addOperationCompleteCallback(this.model.setTodos, ['operation.result'])
.addOperationCompleteCallback(this.setCurrentState, null, ApplicationModel.STATE_OPEN_LIST)
.unloadOnOperationComplete();
;
}
//...
}
84. Operation based
public class ApplicationModel extends ZugspitzeModel
{
//...
public var todoProxy:Service1Proxy = new Service1Proxy;
public var currentState:String = STATE_LOADING;
public var opentTodos:ArrayCollection;
public var completeTodos:ArrayCollection;
public var todo:Todo;
public function setTodos(todos:Array):void
{
var open:Array = new Array;
var complete:Array = new Array;
for each (var todo:Todo in todos) {
if (todo.complete) {
complete.push(todo);
} else {
open.push(todo);
}
}
this.completeTodos = new ArrayCollection(complete);
this.opentTodos = new ArrayCollection(open);
}
//...
}
86. What’s on my Todo List
Skinning workflow
LogService reimplementation
BusyStatus through operations
Flash/Reflex integration
Look at Signals
Filter for Logger
Debug menu
Hudson, Testing, UI Testing, .....