-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Library): add app lifecycle hooks
- Loading branch information
1 parent
23511bd
commit c61d51c
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
extends RefCounted | ||
class_name AppLifecycleHook | ||
|
||
## Base class for executing callbacks at certain points of an app's lifecycle. | ||
## | ||
## This class provides an interface for executing arbitrary callbacks at certain | ||
## points of an application's lifecycle. This can allow [Library] implementations | ||
## the ability to execute actions when apps are about to start, have started, | ||
## or have exited. | ||
|
||
## The type of hook determines where in the application's lifecycle this hook | ||
## should be executed. | ||
enum TYPE { | ||
## Executes right before an app is launched | ||
PRE_LAUNCH, | ||
## Executes right after an app is launched | ||
LAUNCH, | ||
## Executed after app exit | ||
EXIT, | ||
} | ||
|
||
var _hook_type: TYPE | ||
|
||
|
||
func _init(hook_type: TYPE) -> void: | ||
_hook_type = hook_type | ||
|
||
|
||
## Executes whenever an app from this library reaches the stage in its lifecycle | ||
## designated by the hook type. E.g. a `PRE_LAUNCH` hook will have this method | ||
## called whenever an app is about to launch. | ||
func execute(item: LibraryLaunchItem) -> void: | ||
pass | ||
|
||
|
||
## Returns the hook type, which designates where in the application's lifecycle | ||
## the hook should be executed. | ||
func get_type() -> TYPE: | ||
return _hook_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters