Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate more events to EventListener #1777

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public open class EventListener {
*/
public open fun codeLoadStart(): Any? = null

/**
* Invoked when a Zipline is created, after [codeLoadStart] and before any application code is
* loaded.
*/
public open fun ziplineCreated(
zipline: Zipline,
) {
}

/**
* Invoked when code is successfully downloaded and initialized.
*
Expand All @@ -64,6 +73,17 @@ public open class EventListener {
) {
}

/**
* Invoked when a code load is skipped because the cached code isn't up-to-date.
*
* @param startValue the value returned by [codeLoadStart] for the start of this call. This
* is null unless [codeLoadStart] is overridden to return something else.
*/
public open fun codeLoadSkippedNotFresh(
startValue: Any?,
) {
}

/**
* Invoked when a code load fails.
*
Expand Down Expand Up @@ -190,6 +210,15 @@ public open class EventListener {
) {
}

/**
* Invoked when the loader has successfully fetched a manifest, verified it (if necessary), and
* will proceed to download and load each of its modules.
*/
public open fun manifestReady(
manifest: ZiplineManifest,
) {
}

/**
* Invoked when a module load starts. This is the process of loading code into QuickJS.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ internal class RealEventPublisher(
return listener.codeLoadStart()
}

override fun ziplineCreated(
zipline: Zipline,
) {
listener.ziplineCreated(zipline)
}

override fun applicationLoadSuccess(
applicationName: String,
manifestUrl: String?,
Expand All @@ -61,6 +67,14 @@ internal class RealEventPublisher(
listener.codeLoadSkipped(startValue)
}

override fun applicationLoadSkippedNotFresh(
applicationName: String,
manifestUrl: String?,
startValue: Any?,
) {
listener.codeLoadSkippedNotFresh(startValue)
}

override fun applicationLoadFailed(
applicationName: String,
manifestUrl: String?,
Expand Down Expand Up @@ -115,6 +129,14 @@ internal class RealEventPublisher(
listener.manifestVerified(manifest, verifiedKey)
}

override fun manifestReady(
applicationName: String,
manifestUrl: String?,
manifest: ZiplineManifest,
) {
listener.manifestReady(manifest)
}

override fun moduleLoadStart(zipline: Zipline, moduleId: String): Any? {
return listener.moduleLoadStart(moduleId)
}
Expand Down