Skip to content
CCinder
Cinder.setContextProvider

API Reference

Cinder.setContextProvider

Register a runtime context provider so local resolution and fallback can use application state explicitly.

Use setContextProvider() when command resolution needs explicit app state that does not live in semantic tags alone.

Example

ts
4 lines
Cinder.setContextProvider(() => ({
  accountId: currentAccount.id,
  region: currentRegion,
}));

You can also return a promise:

ts
5 lines
Cinder.setContextProvider(async () => {
  return {
    accountId: await getSelectedAccountId(),
  };
});

Important behavior

  • resolve() uses a synchronous provider result when available, otherwise it uses cached context
  • run() awaits fresh async context before local resolution happens
  • fallback requests can also include the injected runtime context

Continue reading