Book a Demo

Author Topic: Broadcast events multiple times in addin  (Read 5256 times)

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Broadcast events multiple times in addin
« on: July 01, 2013, 02:24:26 am »
Hi,

i'm thinking about the usage of the Broadcast event "EA_Onnotifycontextitemmodified" in several different Add-in Parts.

Mainly i call it within my mainclass "Class1 :)".
But i want to use the event in other parts as well, like "class7" oder "class9" (No they are not numeric, it is just to say it more generic)

Is it possible to use the event multiple times with different functionality?
or could I only use it once and have to decide there about the function?

Regards

Stefan
Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Broadcast events multiple times in addin
« Reply #1 on: July 01, 2013, 06:05:48 am »
What about having class7 and class9 as members or references in the main class , and delegate the broadcasted notification where and as often you like?
My AddIn main classes themselves usually doesn't do much more than just this. To name it: I implement it as a Dispatcher. Also I usually prefer to have more (pre-)processed information for the event notification parameters. How you dispatch the events (synchronously/asynchronously) is completely up to you.

Your AddIn main class will only be called once by EA and it's the only one respected by EA (I think it has to be defined as entry point for the assembly). Another main class means another AddIn, if you want to share code for these put this in a separate library.
You should have a look at Geert Bellekens' AddIn Framework library.

HTH
Günther

P.S.: Sorry Stefan that I have just these platitudes for you, but I begin to see your point about 'broadcasted events' by EA. Yes from point of view of the EA App the event is broadcasted to all the AddIns that have the appropriate methods implemented (or a complete set of methods as for the MDG AddIn). From point of view of the AddIn the event notification method implementation is a single entry point.
« Last Edit: July 01, 2013, 08:06:30 am by g.makulik »
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Broadcast events multiple times in addin
« Reply #2 on: July 02, 2013, 03:43:29 pm »
Hmm, I see the issue.
Would it be a good idea to extend the add-in base class and add "real" events to it for all the EA "pseudo" events?

That way you can add all the subscribers you like, without having to change the main add-in class.

Geert

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: Broadcast events multiple times in addin
« Reply #3 on: July 04, 2013, 04:21:46 am »
Hi,

that was the way I did after I realized that I couldn't use the event twice...

-> Created a own event which is triggered by EA's event.  :D

Regard

Stefan
Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Broadcast events multiple times in addin
« Reply #4 on: July 04, 2013, 06:01:02 am »
Quote
Hmm, I see the issue.
Would it be a good idea to extend the add-in base class and add "real" events to it for all the EA "pseudo" events?
Yes, absolutely Geert! That abstracts out a/synchronous event handling.
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Broadcast events multiple times in addin
« Reply #5 on: July 04, 2013, 06:12:01 am »
Somehow it's a bit strange that EA's API does not offer a subscription mechanism out of the box. But as we know the EA developers "think different".

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Broadcast events multiple times in addin
« Reply #6 on: July 04, 2013, 03:32:10 pm »
Quote
Quote
Hmm, I see the issue.
Would it be a good idea to extend the add-in base class and add "real" events to it for all the EA "pseudo" events?
Yes, absolutely Geert! That abstracts out a/synchronous event handling.
I'll put in on my TODO list :)

Geert