Module app hooks

Community Forums/Monkey2 Talk/Module app hooks

Skn3(Posted 2015) [#1]
Would it be possible if a module had scope to hook into certain app hooks. So for example any module can implement a class or define some directive to hook into say for example the app.oncreate().

This way a module can auto register itself/setup certain aspects for runtime. The alternative I use at the moment is InitModuleName() function, but it would be nice if this could be streamlined somehow.


k.o.g.(Posted 2015) [#2]
+1

Would be awesome and helpful


ziggy(Posted 2015) [#3]
If we're not going to have a chance to handle the main app loop directly,then a delegates based event system wouldn't hurt.


GW_(Posted 2015) [#4]
I wouldn't want this as the default behavior though. I see weird race-conditions happening. Perhaps a #directive to enable/disable.


Skn3(Posted 2015) [#5]
Could the order of hooks be called based on the already existing module dependency tree?


dmaz(Posted 2015) [#6]
ok, since this is a new language... why do we need hooks? why can't we have dynamic classes at, at least, compile time let alone runtime? (knowing the performance tradeoffs for runtime)


Skn3(Posted 2015) [#7]
Well any method would do.

Ideally if monkey2 supports more iOS/android callbacks, there would still need to be someway to hook in for this though. However that may be.

The init approach describe in original post might be something that could be added with preprocessor vars?

#APP_INIT += "InitModuleName()"

Bit cludgy though...


dmaz(Posted 2015) [#8]
oh, I see what you want... I saw the module context and replied thinking it was a good for composition. yeah so events/callbacks might be the better for this example.


CopperCircle(Posted 2015) [#9]
As someone who uses allot of modules it would be great to get some form of hooks.