StrangeIoC
0.6.0
The IoC/Binding Framework for Unity3D and C#
|
Interface for a Binder that triggers the instantiation of Commands. More...
Public Member Functions | |
void | ReactTo (object trigger) |
Trigger a key that unlocks one or more Commands. | |
void | ReactTo (object trigger, object data) |
Trigger a key that unlocks one or more Commands and provide a data injection to that Command. | |
void | ReleaseCommand (ICommand command) |
Release a previously retained Command. More... | |
void | Stop (object key) |
Called to halt execution of a currently running command group. | |
new ICommandBinding | Bind< T > () |
Bind a trigger Key by generic Type. | |
new ICommandBinding | Bind (object value) |
Bind a trigger Key by value. | |
new ICommandBinding | GetBinding< T > () |
Retrieve a binding based on the provided Type. | |
Public Member Functions inherited from strange.framework.api.IBinder | |
IBinding | GetBinding (object key) |
Retrieve a binding based on the provided object. | |
IBinding | GetBinding< T > (object name) |
Retrieve a binding based on the provided Key (generic)/Name combo. | |
IBinding | GetBinding (object key, object name) |
Retrieve a binding based on the provided Key/Name combo. | |
IBinding | GetRawBinding () |
Generate an unpopulated IBinding in whatever concrete form the Binder dictates. | |
void | Unbind< T > () |
Remove a binding based on the provided Key (generic) | |
void | Unbind< T > (object name) |
Remove a binding based on the provided Key (generic) / Name combo. | |
void | Unbind (object key) |
Remove a binding based on the provided Key. | |
void | Unbind (object key, object name) |
Remove a binding based on the provided Key / Name combo. | |
void | Unbind (IBinding binding) |
Remove the provided binding from the Binder. | |
void | RemoveValue (IBinding binding, object value) |
Remove a select value from the given binding. | |
void | RemoveKey (IBinding binding, object value) |
Remove a select key from the given binding. | |
void | RemoveName (IBinding binding, object value) |
Remove a select name from the given binding. | |
void | OnRemove () |
The Binder is being removed Override this method to clean up remaining bindings. | |
void | ResolveBinding (IBinding binding, object key) |
Places individual Bindings into the bindings Dictionary as part of the resolving process More... | |
Interface for a Binder that triggers the instantiation of Commands.
Commands are where the logic of your application belongs. These Commands typically focus on a single function, such as adding a View, requesting a service, reading from or saving to a model.
The act of binding events to Commands means that code needn't know anything about an event recipient, or even how the event will be used. For example, a Mediator might send out an event that two View objects collided. A Command would then determine that the result of that event was to Destroy both objects, tell a ScoreKeeper model to change the score and request a message be sent to the server. Whether that example means one Command or three is up to your coding preference... CommandBinder can trigger one Command or multiple Commands off the same event.
Note that CommandBinder also a features sequencing. By default, CommandBinder fires all Commands in parallel. If your binding specifies InSequence()
, commands will run serially, with the option of suspending the chain at any time.
Example bindings:
Bind("someEvent").To<SomeCommand>(); //Works, but poor form to use strings. Use the next example instead Bind(EventMap.SOME_EVENT).To<SomeCommand>(); //Make it a constant Bind(ContextEvent.START).To<StartCommand>().Once(); //Destroy the binding immediately after a single use Bind(EventMap.END_GAME_EVENT).To<FirstCommand>().To<SecondCommand>().To<ThirdGCommand>().InSequence();
See Command for details on asynchronous Commands and cancelling sequences.
void strange.extensions.command.api.ICommandBinder.ReleaseCommand | ( | ICommand | command) |
Release a previously retained Command.
By default, a Command is garbage collected at the end of its Execute()
method. But the Command can be retained for asynchronous calls.
Implemented in strange.extensions.command.impl.CommandBinder.