Skip to content

Feature: Scheduler

Tron edited this page Jan 13, 2023 · 1 revision

━ What's the Objective?

Often times handlers have to be executed at specific period; For instance, you may want to perform some special task right after Assetify's library or modules are loaded/unloaded etc or you may simply want to schedule the handlers and boot them all together at your own specific period for some special purpose. Exactly why scheduler exists!

━ How to Import?

Add the below code once in either of the shared .lua script of the resource you want to use within:

--Declare it globally only once
loadstring(exports.assetify_library:import("scheduler"))()

━ APIs

━ assetify.scheduler.execOnBoot() (Shared)

@Objective: Executes specified function as soon as the library gets booted.
local bool: result = assetify.scheduler.execOnBoot(
  function: exec
)

━ assetify.scheduler.execOnLoad() (Shared)

@Objective: Executes specified function as soon as the library gets loaded.
local bool: result = assetify.scheduler.execOnLoad(
  function: exec
)

━ assetify.scheduler.execOnModuleLoad() (Shared)

@Objective: Executes specified function as soon as the library's modules gets loaded.
local bool: result = assetify.scheduler.execOnModuleLoad(
  function: exec
)

━ assetify.scheduler.execOnResourceLoad() (Shared)

@Objective: Executes specified function as soon as the current hooked resource gets loaded.
local bool: result = assetify.scheduler.execOnResourceLoad(
  function: exec
)

━ assetify.scheduler.execOnResourceFlush() (Shared)

@Objective: Executes specified function as soon as the current hooked resource gets flushed.
local bool: result = assetify.scheduler.execOnResourceFlush(
  function: exec
)

━ assetify.scheduler.execOnResourceUnload() (Shared)

@Objective: Executes specified function as soon as the current hooked resource gets unloaded.
local bool: result = assetify.scheduler.execOnResourceUnload(
  function: exec
)

━ assetify.scheduler.execScheduleOnBoot() (Shared)

@Objective: Schedules an execution to be fired as soon as the library gets booted.
⚠️ These schedules are inactive by default, you must boot them via assetify.scheduler.boot as per your requirements!
local bool: result = assetify.scheduler.execScheduleOnBoot(
  function: exec
)

━ assetify.scheduler.execScheduleOnLoad() (Shared)

@Objective: Schedules an execution to be fired as soon as the library gets loaded.
⚠️ These schedules are inactive by default, you must boot them via assetify.scheduler.boot as per your requirements!
local bool: result = assetify.scheduler.execScheduleOnLoad(
  function: exec
)

━ assetify.scheduler.execScheduleOnModuleLoad() (Shared)

@Objective: Schedules an execution to be fired as soon as the library's modules gets loaded.
⚠️ These schedules are inactive by default, you must boot them via assetify.scheduler.boot as per your requirements!
local bool: result = assetify.scheduler.execScheduleOnModuleLoad(
  function: exec
)

━ assetify.scheduler.execScheduleOnResourceLoad() (Shared)

@Objective: Schedules an execution to be fired as soon as the current hooked resource gets loaded.
⚠️ These schedules are inactive by default, you must boot them via assetify.scheduler.boot as per your requirements!
local bool: result = assetify.scheduler.execScheduleOnResourceLoad(
  function: exec
)

━ assetify.scheduler.execScheduleOnResourceFlush() (Shared)

@Objective: Schedules an execution to be fired as soon as the current hooked resource gets flushed.
⚠️ These schedules are inactive by default, you must boot them via assetify.scheduler.boot as per your requirements!
local bool: result = assetify.scheduler.execScheduleOnResourceFlush(
  function: exec
)

━ assetify.scheduler.execScheduleOnResourceUnload() (Shared)

@Objective: Schedules an execution to be fired as soon as the current hooked resource gets unloaded.
⚠️ These schedules are inactive by default, you must boot them via assetify.scheduler.boot as per your requirements!
local bool: result = assetify.scheduler.execScheduleOnResourceUnload(
  function: exec
)

━ assetify.scheduler.boot() (Shared)

@Objective: Boots up all scheduled executions.
local bool: result = assetify.scheduler.boot()
Clone this wiki locally