Closed TrevorDev closed 8 years ago
@TrevorDev This is partially due to how UWP APIs have been designed and how they are "projected" to JavaScript (see https://msdn.microsoft.com/en-us/library/mt125480(v=vs.94).aspx). The underlying code (not part of this module) creates global "Windows" variable (namespace) and sub-namespaces. These "namespaces" are all non-writable/non-configurable probably for consistency/security reasons. As a result ```var Windows = ..." has no effect. I agree with you that your changed version looks more consistent with node style.
Thanks for your reply.
Would it be unreasonable to create a feature request for whichever team built that projection function to expose an alternative api to project UWP api's to local variables instead of globals? I am not sure what you mean by "consistency/security reasons" as this is inconsistent with node style and I am also not familiar with windows API security.
I understand that this may be low priority/nitpicking as currently this does not block any functionality but global variables being defined without user explicitly doing so feels like a red flag in many programming environments (not just node) and even feels weird to me when writing a uwp js app and would much prefer a more similar style to http://electron.atom.io/.
@TrevorDev Sorry I didn't have a good answer and didn't reply before you close this issue. By "consistency" I mean consistency with other platforms like c#/JavaScript UWP app. The names and API calls always appear as Windows.xxx...
. By "security" I mean it is non-configurable so code cannot replace Windows.xxx
with sth. else.
We'll note your feedback and would consider this issue in future development of the UWP/JavaScript projection. Thanks for your comment.
:+1: Thanks
Hey I am wondering why the sample code is like the following:
var uwp = require('uwp'); uwp.projectNamespace("Windows"); Windows.Storage.KnownFolders.documentsLibrary.createFileAsync
instead of
var uwp = require('uwp'); var Windows = uwp.projectNamespace("Windows"); Windows.Storage.KnownFolders.documentsLibrary.createFileAsync
I don't know if it's just me but variables being defined without a definition feels very uncomfortable. What is the reason for it working like this?