From 28d7d5ceec2564386e6c63f2aa6e127af9bd6911 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Sat, 30 Apr 2016 13:31:10 -0400 Subject: [PATCH] feat(plugin): add wrapper for instance properties this wrapper will be able to handle get/set functions for any instance property --- src/plugins/plugin.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index 4c007060b..71a6a9f17 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -317,3 +317,22 @@ export function CordovaProperty(target: Function, key: string, descriptor: Typed return descriptor; } + +/** + * @private + * @param target + * @param key + * @param descriptor + * @constructor + */ +export function InstanceProperty(target: Function, key: string, descriptor: TypedPropertyDescriptor) { + descriptor.get = function() { + return this._objectInstance[key]; + }; + + descriptor.get = function(...args: any[]) { + return this._objectInstance[key] = args[0]; + }; + + return descriptor; +} \ No newline at end of file