Last active
July 13, 2018 13:17
-
-
Save molcik/16a723734c3d61c7cc74d7baf2c1c8c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* SessionStorage for storing string values | |
*/ | |
export function SessionStorage( | |
target: Object, // The prototype of the class | |
decoratedPropertyName: string // The name of the property | |
) { | |
// get and set methods | |
Object.defineProperty(target, decoratedPropertyName, { | |
get: function () { | |
return sessionStorage.getItem(decoratedPropertyName) || ''; | |
}, | |
set: function (newValue) { | |
sessionStorage.setItem(decoratedPropertyName, newValue); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment