Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactored observe and route so they don't share attributes

  • Loading branch information...
commit 45100bb165a07b924e300d25d7547d7829298863 1 parent 9c4168e
@seanhess authored
View
2  examples/FlickrBook/src/flickr/glue/MainGlue.mxml
@@ -26,8 +26,6 @@
</Glue>
-
-
<!-- VIEWS -->
<Glue>
<views:MainUI id="main"/>
View
BIN  source/bin/Glue.swc
Binary file not shown
View
BIN  source/libs/Bifff0.4.b.swc
Binary file not shown
View
37 source/src/net/seanhess/glue/GlueListen.as
@@ -0,0 +1,37 @@
+package net.seanhess.glue
+{
+ import flash.events.Event;
+ import flash.events.IEventDispatcher;
+
+ import net.seanhess.bifff.behaviors.Listen;
+
+ [Event(name="call", type="flash.events.Event")]
+ public class GlueListen extends Listen implements IGlueAction
+ {
+ protected var on:IEventDispatcher;
+
+ public function applyAction(target:*):void
+ {
+ this.target = target;
+ }
+
+ override protected function getDispatcher(target:*):IEventDispatcher
+ {
+ var dispatcher:IEventDispatcher;
+
+ if (on)
+ dispatcher = on;
+
+ else
+ dispatcher = super.getDispatcher(target);
+
+ return dispatcher;
+ }
+
+ override protected function eventFiring(target:*, event:Event):void
+ {
+ super.eventFiring(target, event);
+ (parent.selector as Glue).setCurrentInstance(target);
+ }
+ }
+}
View
36 source/src/net/seanhess/glue/Observe.as
@@ -3,24 +3,11 @@ package net.seanhess.glue
import flash.events.Event;
import flash.events.IEventDispatcher;
- import net.seanhess.bifff.behaviors.Listen;
-
/**
- * Usage: <Observe controller="{myController}" event="eventType" call="me.doAction()"/>
- *
- * Use this tag to listen to events fired from a controller, and respond to them with
- * your current view or controller.
+ * Usage: See online docs
*/
- [Event(name="call", type="flash.events.Event")]
- public class Observe extends Listen implements IGlueAction
+ public class Observe extends GlueListen
{
- protected var on:IEventDispatcher;
-
- public function applyAction(target:*):void
- {
- this.target = target;
- }
-
public function set model(value:IEventDispatcher):void
{
on = value;
@@ -30,24 +17,5 @@ package net.seanhess.glue
{
on = value;
}
-
- override protected function getDispatcher(target:*):IEventDispatcher
- {
- var dispatcher:IEventDispatcher;
-
- if (on)
- dispatcher = on;
-
- else
- dispatcher = super.getDispatcher(target);
-
- return dispatcher;
- }
-
- override protected function eventFiring(target:*, event:Event):void
- {
- super.eventFiring(target, event);
- (parent.selector as Glue).setCurrentInstance(target);
- }
}
}
View
19 source/src/net/seanhess/glue/Route.as
@@ -1,25 +1,10 @@
package net.seanhess.glue
{
/**
- * Usage: <Route event="userEvent" call="someController.action()"/>
- * Usage: <Route child="{me.someButton}" event="click" call="someController.action()"/>
- *
- * Used to route view events to a controller. Although Route uses
- * Observe under-the-hood, you should always use the Route tag
- * to listen to a view.
+ * See online docs
*/
- public class Route extends Observe
+ public class Route extends GlueListen
{
- /**
- * If child is specified, will listen to whatever you set
- * the child to for the event instead of your view. You
- * should only ever set child to something within your view.
- *
- * Most of the time you should NOT set this property, but
- * should have your views dispatch events themselves. For
- * example, a login view could dispatch a custom "login" event,
- * and it would look like <Route event="login" call="loginController.login()"/>
- */
public function set child(value:*):void
{
on = value;
Please sign in to comment.
Something went wrong with that request. Please try again.