Author Topic: Receiving events?  (Read 5570 times)

Offline David Serrano

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 503
Receiving events?
« on: 2009 April 03 01:11:56 »
Hmmm I just have a couple of evil ideas cooking up deep at the back of my mind... :twisted:

I see that Statistics is able to follow the changes made to an image and show the new set of statistics without requiring the user to take any action. Could this, or something similar, be done from javascript? Are there any means to "subscribe" to an view and receive events when something happens to it?

I don't think so, since this would require the script to run for an indefinite amount of time, concurrently with any other actions the user may want to take... but here is the question anyway!

Edit: changed "image" to "view".
--
 David Serrano

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Receiving events?
« Reply #1 on: 2009 April 03 23:04:09 »
Would be nice.  In fact an object like the statistics implements what is called an 'observer' pattern in OO. Having the possibility to implements this kind of behavior in javascript could be useful for example to have alternate measures on an image.

In principle there would be ne need for a script to run waiting for event, this would be some sort of callback. I do not know if the javascript used by PI would allow this.

bitli

Offline David Serrano

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 503
Receiving events?
« Reply #2 on: 2009 April 06 15:06:31 »
Enabling callbacks sounds like a great idea. Users would create functions with predefined names, that would be called whenever certain conditions were met:

- Type of event.
- Image properties (identifier, color depth, dimensions...).
- Current workspace.
- Hooks before/after execution of specific/all processes, or before/after a workspace change.
- ... you name it!
--
 David Serrano