Skip to content

IUtilWrapper

Qamsari edited this page Aug 17, 2021 · 4 revisions

This interface expose some helper methods.

export default interface IUtilWrapper {
  cloneDeep<T>(obj: T): T;
  defaultsDeep<T>(data: Partial<T>, defaults: Partial<T>): T;
  getLibAsync(objectName: string, url: string): Promise<any>;
  toNode(rawHtml: string): DocumentFragment;
  toHTMLElement(rawXml: string): HTMLElement;
  getComponentAsync(context: IContext, key: string): Promise<any>;

  source: ISourceWrapper;
}

Properties

Methods

  • cloneDeep()
    Create deep clone copy of object passed as parameter.

  • defaultsDeep(data,defaults)
    This method create deep clone copy of data object and set default value for those fields that present in defaults object and not set in data object.

  • getLibAsync(objectName,url)
    this method check for object that her name send as objectName. if object already exist (not undefined or null) return it. otherwise load script from url and add to DOM as script tag. then return object. this method wait until script loaded.

  • toNode(rowHtml)
    Create DocumentFragment from rawHtml and return it. rawHtml is string that represent raw html;

  • toHTMLElement(rawXml)
    Create HTMLElement from rawXML and return it. rawXML is string that represent raw html but in Well-formed XML. this method use DOMParser.parseFromString() with mimetype set to application/xml.

  • getComponentAsync(context,key) Finding component class by search key in context related repository and return new instance of it. for more information about context visit IContext.

Clone this wiki locally