How to use the esp-js.EspDecoratorUtil.getCustomData function in esp-js

To help you get started, we’ve selected a few esp-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esp / esp-js / packages / esp-js-react / src / connectableComponent.tsx View on Github external
private _getRenderModel(model: any): TModel {
        // does the given model have a decorated function we can invoke to get a different model to render?
        if (EspDecoratorUtil.hasMetadata(model)) {
            let metadata: GetEspReactRenderModelMetadata = EspDecoratorUtil.getCustomData(model, GetEspReactRenderModelConsts.CustomDataKey);
            if (metadata) {
                return model[metadata.functionName]();
            }
        }
        // else see if there is a function with name GetEspReactRenderModelConsts.HandlerFunctionName we can invoke to get a different model to render?
        let renderModelGetter = model[GetEspReactRenderModelConsts.HandlerFunctionName];
        if (renderModelGetter && utils.isFunction(renderModelGetter)) {
            return renderModelGetter.call(model);
        }
        // else just return the default model
        return model;
    }
}