Skip to main content
Glama
useEditedContentRenderer.ts1.31 kB
import { computed, Injectable, InjectionToken, inject, type Signal, } from '@angular/core'; import type { KeyPath } from '@intlayer/types'; export interface EditedContentActions { getEditedContentValue(dictionaryKey: string, keyPath: KeyPath[]): unknown; } export const EDITED_CONTENT_ACTIONS_TOKEN = new InjectionToken<EditedContentActions | null>('editedContentActions'); @Injectable({ providedIn: 'root', }) export class EditedContentRendererService { /** * Mirrors the React hook one-for-one. */ useEditedContentRenderer( dictionaryKey: string, keyPath: KeyPath[], fallback: unknown ): Signal<unknown> { const editedContentContext = inject(EDITED_CONTENT_ACTIONS_TOKEN, { optional: true, }); return computed(() => { const edited = editedContentContext?.getEditedContentValue( dictionaryKey, keyPath ) as string | undefined; return edited ?? fallback; }); } } /** * Standalone function that can be used like the Vue composable */ export const useEditedContentRenderer = ( dictionaryKey: string, keyPath: KeyPath[], fallback: unknown ): Signal<unknown> => { const service = inject(EditedContentRendererService); return service.useEditedContentRenderer(dictionaryKey, keyPath, fallback); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server