remove prosperon.on and prosperon.dispatch
This commit is contained in:
@@ -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
|
// Get hidden modules from prosperon.hidden before stripping it
|
||||||
var hidden = prosperon.hidden
|
var hidden = prosperon.hidden
|
||||||
var actor_mod = hidden.actor
|
var actor_mod = hidden.actor
|
||||||
@@ -43,20 +23,6 @@ delete prosperon.hidden
|
|||||||
var os = use_embed('os')
|
var os = use_embed('os')
|
||||||
var js = use_embed('js')
|
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')
|
var io = use_embed('io')
|
||||||
|
|
||||||
globalThis.console = console_mod
|
globalThis.console = console_mod
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ function step() {
|
|||||||
var dt = now - last_frame_time
|
var dt = now - last_frame_time
|
||||||
last_frame_time = now
|
last_frame_time = now
|
||||||
|
|
||||||
// event.engine_input(e => prosperon.dispatch(e.type, e))
|
|
||||||
layout.newframe()
|
layout.newframe()
|
||||||
|
|
||||||
prosperon.appupdate(dt)
|
prosperon.appupdate(dt)
|
||||||
|
|||||||
@@ -786,24 +786,25 @@ static void signal_handler(int sig)
|
|||||||
case SIGTERM: str = "SIGTERM"; break;
|
case SIGTERM: str = "SIGTERM"; break;
|
||||||
}
|
}
|
||||||
if (!str) return;
|
if (!str) return;
|
||||||
for (int i = 0; i < shlen(actors); i++) {
|
|
||||||
prosperon_rt *main = actors[i].value;
|
/* Push a quit event to the SDL event queue */
|
||||||
JSContext *js = main->context;
|
SDL_Event quit_event;
|
||||||
script_evalf(js, "prosperon.dispatch('%s')", str);
|
quit_event.type = SDL_EVENT_QUIT;
|
||||||
}
|
SDL_PushEvent(&quit_event);
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
if (sig == SIGTERM || sig == SIGINT) exit(1);
|
if (sig == SIGTERM || sig == SIGINT) exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void exit_handler(void)
|
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);
|
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;
|
int status;
|
||||||
SDL_BroadcastCondition(queue_cond);
|
SDL_BroadcastCondition(queue_cond);
|
||||||
for (int i = 0; i < arrlen(runners); i++)
|
for (int i = 0; i < arrlen(runners); i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user