Skip to content

Add startup lifecycle hook#1531

Merged
inlined merged 5 commits intomasterfrom
inlined.init-fn
Mar 7, 2024
Merged

Add startup lifecycle hook#1531
inlined merged 5 commits intomasterfrom
inlined.init-fn

Conversation

@inlined
Copy link
Copy Markdown
Member

@inlined inlined commented Mar 2, 2024

Adds a new function that can be used at global scope to perform initialization in production that won't be called during discovery. In this function, params will be guaranteed to have actual values.

Usage:

const apiKey = params.defineSecret("API_KEY");

onInit(() => {
  someSDK.init(apiKey.value);
});

@inlined inlined requested a review from blidd-google March 2, 2024 01:42
Copy link
Copy Markdown
Contributor

@blidd-google blidd-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread src/common/onInit.ts
import * as logger from "../logger";

let initCallback: (() => unknown) | null = null;
let didInit = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we leave globals as camel-cased or in CAPS?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically CAPS is for consts, which these aren't

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants