diff --git a/src/Umbraco.Web.UI.Client/src/stories/umb-element.mdx b/src/Umbraco.Web.UI.Client/src/stories/umb-element.mdx index be0ac5d44e..e3e6e79dde 100644 --- a/src/Umbraco.Web.UI.Client/src/stories/umb-element.mdx +++ b/src/Umbraco.Web.UI.Client/src/stories/umb-element.mdx @@ -10,7 +10,7 @@ The Element implements the Controller Host and provides a few shortcut methods f The methods are (_note this can be out of date, we need to look into how we can ensure this Doc originates from code._) -``` +```ts observe(source: Observable, callback: (_value: T) => void, unique?: string): UmbObserverController provideContext(alias: string | UmbContextToken, instance: R): UmbContextProviderController @@ -20,7 +20,7 @@ consumeContext(alias: string | UmbContextToken, callback: UmbCon Use these for an smooth consumption, like this request for a Context API using a simple string context, where the callback value is unknown -``` +```ts this.consumeContext('requestThisContextAlias', (context) => { // Notice this is a subscription, as context might change or a new one appears. console.log("I've got the context", context); @@ -29,7 +29,7 @@ this.consumeContext('requestThisContextAlias', (context) => { Or use the UmbContextToken type to define the type of the context, like this -``` +```ts const contextAlias = new UmbContextToken('description of context for debugging purposes'); this.consumeContext(contextAlias, (context) => { diff --git a/src/Umbraco.Web.UI.Client/src/stories/umbelement.mdx b/src/Umbraco.Web.UI.Client/src/stories/umbelement.mdx deleted file mode 100644 index 63324c4f92..0000000000 --- a/src/Umbraco.Web.UI.Client/src/stories/umbelement.mdx +++ /dev/null @@ -1,39 +0,0 @@ -import { Meta } from '@storybook/addon-docs'; - - - -# Umbraco Element - -This element can be used as the base of any Element. -Do this if you need to Observe Data, Consume or Provide a Context API or use a Resource. -The Element implements the Controller Host and provides a few shortcut methods for initializing some Controllers. - -The methods are (_note this can be out of date, we need to look into how we can ensure this Doc originates from code._) - -```typescript -observe(source: Observable, callback: (_value: T) => void, unique?: string): UmbObserverController - -provideContext(alias: string | UmbContextToken, instance: R): UmbContextProviderController - -consumeContext(alias: string | UmbContextToken, callback: UmbContextCallback): UmbContextConsumerController -``` - -Use these for an smooth consumption, like this request for a Context API using a simple string context, where the callback value is unknown - -```typescript -this.consumeContext('requestThisContextAlias', (context) => { - // Notice this is a subscription, as context might change or a new one appears. - console.log("I've got the context", context); -}); -``` - -Or use the UmbContextToken type to define the type of the context, like this - -```typescript -const contextAlias = new UmbContextToken('description of context for debugging purposes'); - -this.consumeContext(contextAlias, (context) => { - // Notice this is a subscription, as context might change or a new one appears, but the value is strongly typed - console.log("I've got the context", context); -}); -```