File

compodocs/smartedit/services/SeNamespaceService.ts

Index

Properties
Methods
Accessors

Constructor

constructor(logService: LogService)
Parameters :
Name Type Optional
logService LogService No

Methods

Private _reprocessPage
_reprocessPage()
Returns : void
renderComponent
renderComponent(componentId: string, componentType?: string, parentId?: string)
Parameters :
Name Type Optional
componentId string No
componentType string Yes
parentId string Yes
Returns : boolean

Properties

reprocessPage
Default value : debounce(this._reprocessPage.bind(this), 50)

Accessors

namespace
getnamespace()
import { BootstrapPayload, LogService, SeDowngradeService } from 'smarteditcommons';
import { debounce } from 'lodash';

declare global {
    /* @internal */
    interface InternalSmartedit {
        SmarteditFactory: (payload: BootstrapPayload) => any;
    }
    interface Window {
        smartedit: SmarteditNamespace;
    }
}

export interface SmarteditNamespace {
    addOnReprocessPageListener: (callback: () => void) => void;
    reprocessPage: () => void;
    applications: string[];
    domain: string;
    smarteditroot: string;
    renderComponent?: (componentId: string, componentType?: string, parentId?: string) => any;
}

/* @internal */
@Injectable()
export class SeNamespaceService {
    reprocessPage = debounce(this._reprocessPage.bind(this), 50);

    constructor(private logService: LogService) {}

    // explain slot for multiple instances of component scenario
    renderComponent(componentId: string, componentType?: string, parentId?: string): boolean {
        return this.namespace && typeof this.namespace.renderComponent === 'function'
            ? this.namespace.renderComponent(componentId, componentType, parentId)
            : false;
    }

    private _reprocessPage(): void {
        if (this.namespace && typeof this.namespace.reprocessPage === 'function') {
            this.namespace.reprocessPage();
            return;
        }
        this.logService.warn('No reprocessPage function defined on smartediFt namespace');
    }

    private get namespace(): SmarteditNamespace {
        window.smartedit = window.smartedit || ({} as SmarteditNamespace);
        return window.smartedit;
    }
}

result-matching ""

    No results matching ""