Skip to content

Commit 18580c7

Browse files
committed
disableSendToAll flag added.
1 parent 94d3759 commit 18580c7

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

src/org/mvcexpress/MvcExpress.as

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public class MvcExpress {
4343
* ATTENTION : it will work only with compile variable CONFIG:debug set to true.
4444
*/
4545
static public var debugFunction:Function = null;
46+
47+
/**
48+
* Flag to force sendMessageToAll function throw an error in debug mode.
49+
* For people who don't what this feature in.
50+
*/
51+
static public var disableSendToAllFeature:Boolean = false;
4652

4753
}
4854
}

src/org/mvcexpress/core/ModuleBase.as

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ public class ModuleBase {
133133
_messenger.send(type, params);
134134
}
135135

136+
/**
137+
* Sends message to all existing modules.
138+
* @param type message type to find needed handlers
139+
* @param params parameter object that will be sent to all handler and execute functions as single parameter.
140+
*/
141+
public function sendMessageToAll(type:String, params:Object = null):void {
142+
_messenger.sendToAll(type, params);
143+
}
144+
136145
//----------------------------------
137146
// utils
138147
//----------------------------------

src/org/mvcexpress/core/messenger/Messenger.as

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,15 @@ public class Messenger {
178178
* @param params parameter object that will be sent to all handler and execute functions as single parameter.
179179
*/
180180
public function sendToAll(type:String, params:Object = null):void {
181-
//if (CONFIG::disableSendToAll == true) {
182-
//throw Error("sendToAll feature is disabled by compile argument: '-define=CONFIG::disableSendToAll,true'.");
183-
//}
181+
// debug this action
182+
CONFIG::debug {
183+
if (MvcExpress.disableSendToAllFeature) {
184+
throw Error("sendMessageToAll feature is disabled by MvcExpress.disableSendToAllFeature set to true.");
185+
}
186+
if (MvcExpress.debugFunction != null) {
187+
MvcExpress.debugFunction("•>>> Messenger.sendToAll > type : " + type + ", params : " + params);
188+
}
189+
}
184190
use namespace pureLegsCore;
185191
ModuleManager.sendMessageToAll(type, params);
186192
}

src/org/mvcexpress/modules/ModuleCore.as

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ public class ModuleCore {
9595
moduleBase.sendMessage(type, params);
9696
}
9797

98+
/**
99+
* Sends message to all existing modules.
100+
* @param type message type to find needed handlers
101+
* @param params parameter object that will be sent to all handler and execute functions as single parameter.
102+
*/
103+
protected function sendMessageToAll(type:String, params:Object = null):void {
104+
moduleBase.sendMessageToAll(type, params);
105+
}
106+
98107
//----------------------------------
99108
// Debug
100109
//----------------------------------

0 commit comments

Comments
 (0)