remove prosperon.on and prosperon.dispatch

This commit is contained in:
2025-05-28 13:51:58 -05:00
parent 758b3e4704
commit a39f287a88
3 changed files with 12 additions and 46 deletions

View File

@@ -7,26 +7,6 @@ globalThis.log = new Proxy({}, {
}
})
var listeners = new Map()
prosperon.on = function(type, callback) {
if (!listeners.has(type)) listeners.set(type, [])
listeners.get(type).push(callback)
return function() {
var arr = listeners.get(type)
if (!arr) return
var idx = arr.indexOf(callback)
if (idx >= 0) arr.splice(idx,1)
}
}
prosperon.dispatch = function(type, data) {
var arr = listeners.get(type)
if (!arr) return
for (var callback of arr) callback(data)
}
// Get hidden modules from prosperon.hidden before stripping it
var hidden = prosperon.hidden
var actor_mod = hidden.actor
@@ -43,20 +23,6 @@ delete prosperon.hidden
var os = use_embed('os')
var js = use_embed('js')
prosperon.on('SIGINT', function() {
os.exit(1)
})
prosperon.on('SIGABRT', function() {
console.error(new Error('SIGABRT'))
os.exit(1)
})
prosperon.on('SIGSEGV', function() {
console.error(new Error('SIGSEGV'))
os.exit(1)
})
var io = use_embed('io')
globalThis.console = console_mod

View File

@@ -22,7 +22,6 @@ function step() {
var dt = now - last_frame_time
last_frame_time = now
// event.engine_input(e => prosperon.dispatch(e.type, e))
layout.newframe()
prosperon.appupdate(dt)

View File

@@ -786,24 +786,25 @@ static void signal_handler(int sig)
case SIGTERM: str = "SIGTERM"; break;
}
if (!str) return;
for (int i = 0; i < shlen(actors); i++) {
prosperon_rt *main = actors[i].value;
JSContext *js = main->context;
script_evalf(js, "prosperon.dispatch('%s')", str);
}
/* Push a quit event to the SDL event queue */
SDL_Event quit_event;
quit_event.type = SDL_EVENT_QUIT;
SDL_PushEvent(&quit_event);
SDL_Quit();
if (sig == SIGTERM || sig == SIGINT) exit(1);
}
static void exit_handler(void)
{
for (int i = 0; i < shlen(actors); i++) {
prosperon_rt *main = actors[i].value;
JSContext *js = main->context;
script_evalf(js, "prosperon.dispatch('exit')");
}
SDL_SetAtomicInt(&engine_shutdown, 1);
/* Push a terminating event to the SDL event queue */
SDL_Event terminating_event;
terminating_event.type = SDL_EVENT_TERMINATING;
SDL_PushEvent(&terminating_event);
int status;
SDL_BroadcastCondition(queue_cond);
for (int i = 0; i < arrlen(runners); i++)