Configuration object containing the context token
A property decorator function
import {provideContext} from '@umbraco-cms/backoffice/context-api';
import {UMB_WORKSPACE_CONTEXT} from './workspace.context-token.js';
class MyWorkspaceElement extends UmbLitElement {
// Standard decorators - requires 'accessor' keyword
@provideContext({context: UMB_WORKSPACE_CONTEXT})
accessor workspaceContext = new UmbWorkspaceContext(this);
// Legacy decorators - works without 'accessor'
@provideContext({context: UMB_WORKSPACE_CONTEXT})
workspaceContext = new UmbWorkspaceContext(this);
}
// For dynamic updates, store the state inside the context instance
class MyContext extends UmbControllerBase {
someProperty = new UmbStringState('initial value');
}
class MyElement extends UmbLitElement {
@provideContext({context: MY_CONTEXT})
private _myContext = new MyContext(this);
updateValue(newValue: string) {
this._myContext.someProperty.setValue(newValue);
}
}
A property decorator that creates an UmbContextProviderController to provide a context value to child elements via the Umbraco Context API.
This decorator supports both modern "standard" decorators (Stage 3 TC39 proposal) and legacy TypeScript experimental decorators for backward compatibility.
The provider is created once during initialization with the property's initial value. To update the provided value dynamically, keep a state inside the provided context instance and update that state as needed. The context instance itself should remain the same. You can use any of the Umb{*}State classes.