Files
Aurora.3/code/datums/callback-usage.txt
Matt Atlas dd482c63af Update the codebase to 515. (#15553)
* Update the codebase to 515.

* edit that

* WHOOPS

* maor

* maybe works

* libcall and shit

* do that too

* remove that

* auxtools isnt updated so get rid of it

* actually remove auxtools lol

Co-authored-by: Matt Atlas <liermattia@gmail.com>
2023-01-23 21:21:37 +01:00

43 lines
1.6 KiB
Plaintext

USAGE:
var/datum/callback/C = new(object|null, TYPE_PROC_REF(type, path|"procstring"), arg1, arg2, ... argn)
var/timerid = addtimer(C, time, timertype)
OR
var/timerid = addtimer(CALLBACK(object|null, TYPE_PROC_REF(type, path|procstring), arg1, arg2, ... argn), time, timertype)
Note: proc strings can only be given for datum proc calls, global procs must be proc paths
Also proc strings are strongly advised against because they don't compile error if the proc stops existing
See the note on proc typepath shortcuts
INVOKING THE CALLBACK:
var/result = C.Invoke(args, to, add) //additional args are added after the ones given when the callback was created
OR
var/result = C.InvokeAsync(args, to, add) //Sleeps will not block, returns . on the first sleep (then continues on in the "background" after the sleep/block ends), otherwise operates normally.
OR
INVOKE_ASYNC(<CALLBACK args>) to immediately create and call InvokeAsync
PROC TYPEPATH SHORTCUTS (these operate on paths, not types, so to these shortcuts, datum is NOT a parent of atom, etc...)
global proc while in another global proc:
.procname
Example:
CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(some_proc_here))
proc defined on current(src) object (when in a /proc/ and not an override) OR overridden at src or any of it's parents:
.procname
Example:
CALLBACK(src, PROC_REF(some_proc_here))
when the above doesn't apply:
.proc/procname
Example:
CALLBACK(src, PROC_REF(some_proc_here))
proc defined on a parent of a some type:
/some/type/.proc/some_proc_here
Other wise you will have to do the full typepath of the proc (/type/of/thing/proc/procname)