Files
NativeScript/tns-core-modules/ui/builder/special-properties.ts
Hristo Deshev 629eb6e683 Use relative imports in tns-core-modules.
Use tns-core-modules/* imports in outside code (apps, tests, etc)
2017-03-13 14:37:59 +02:00

24 lines
780 B
TypeScript

import { View } from "../core/view";
export type PropertySetter = (instance: View, propertyValue: any) => void;
var specialProperties: Map<string, PropertySetter> = new Map<string, PropertySetter>();
function specialPropertyKey(name: string) {
return name.toLowerCase();
}
export function registerSpecialProperty(name: string, setter: PropertySetter): void {
let propertyKey = specialPropertyKey(name);
if (specialProperties.has(propertyKey)) {
throw new Error(`Property for ${propertyKey} already registered`);
} else {
specialProperties.set(propertyKey, setter);
}
}
export function getSpecialPropertySetter(name: string): PropertySetter {
let propertyKey = specialPropertyKey(name);
return specialProperties.get(propertyKey);
}