| |
 |
Tuesday, August 27, 2002 |
Watch out for redundant event subscriptions when using Groove's ScriptHost components
If you define a component connection for Groove's ScriptHost components, the events provided by the component are automatically subscribed to:
<g:ComponentConnections> <g:Connection ConnectionID="0" Name="MyDataModelDelegate"/> </g:ComponentConnections>
In the case above, event handlers can be implemented in JavaScript by defining functions that use "MyDataModelDelegate_" as a prefix (e.g. "function MyDataModelDelegate_OnSomeEvent").
If you have JavaScript code defined in the code block that attempts to manually subscribe for events using the ConnectObject/Advise method, you will be providing the prefix for defining functions.
function Initialize () { var pITool = PropertyList.OpenProperty(PROPERTY_TOOL); var pIDelegateComponent = pITool.OpenDelegateComponent(); var pIMyDataModelDelegate = pIDelegateComponent.IMyDataModelDelegate; ConnectObject(pIMyDataModelDelegate, "pIMyDataModelDelegate_", true); }
In the case above, event handlers can be implemented in JavaScript by defining functions that use "pIMyDataModelDelegate_" as a prefix (e.g. "function pIMyDataModelDelegate_OnSomeEvent").
The problem to watch out for is when you have both a component connection and code that manually subscribes for events from the same component - the ScriptHost component will always perform component connection based event subscriptions first. Additionally, any subsequent attempts to subscribe for events will not actually do anything, and no errors or warnings will be given. What this means is that if you only define an event handler for the manual subscription, those events will never get triggered.
9:41:23 AM
|
|
© Copyright 2005 Paresh Suthar.
|
|
|
|
| August 2002 |
| Sun |
Mon |
Tue |
Wed |
Thu |
Fri |
Sat |
| |
|
|
|
1 |
2 |
3 |
| 4 |
5 |
6 |
7 |
8 |
9 |
10 |
| 11 |
12 |
13 |
14 |
15 |
16 |
17 |
| 18 |
19 |
20 |
21 |
22 |
23 |
24 |
| 25 |
26 |
27 |
28 |
29 |
30 |
31 |
| Jul Sep |
|
|