How to use the metal.getFunctionName function in metal

To help you get started, we’ve selected a few metal 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 metal / metal.js / packages / metal-component / src / events / events.js View on Github external
export function getComponentFn(component, fnName) {
	if (isFunction(component[fnName])) {
		return component[fnName].bind(component);
	} else {
		console.error(`No function named ${fnName} was found in the component
			"${getFunctionName(component.constructor)}". Make sure that you specify
			valid function names when adding inline listeners`
		);
	}
}
github metal / metal.js / packages / metal-state / src / validators.js View on Github external
function composeError(error, name, context) {
	const compName = context ? getFunctionName(context.constructor) : null;
	const renderer = context && context.getRenderer && context.getRenderer();
	const parent = renderer && renderer.getParent && renderer.getParent();
	const parentName = parent ? getFunctionName(parent.constructor) : null;
	const location = parentName
		? `Check render method of '${parentName}'.`
		: '';
	return new Error(
		`Invalid state passed to '${name}'.` +
			` ${error} Passed to '${compName}'. ${location}`
	);
}
github metal / metal.js / packages / metal-state / src / validators.js View on Github external
function composeError(error, name, context) {
	const compName = context ? getFunctionName(context.constructor) : null;
	const renderer = context && context.getRenderer && context.getRenderer();
	const parent = renderer && renderer.getParent && renderer.getParent();
	const parentName = parent ? getFunctionName(parent.constructor) : null;
	const location = parentName
		? `Check render method of '${parentName}'.`
		: '';
	return new Error(
		`Invalid state passed to '${name}'.` +
			` ${error} Passed to '${compName}'. ${location}`
	);
}
github metal / metal.js / packages / metal-component / src / ComponentRegistry.js View on Github external
static register(constructorFn, opt_name) {
		let name = opt_name;
		if (!name) {
			if (constructorFn.hasOwnProperty('NAME')) {
				name = constructorFn.NAME;
			} else {
				name = getFunctionName(constructorFn);
			}
		}
		constructorFn.NAME = name;
		ComponentRegistry.components_[name] = constructorFn;
	}
}