[AC-3398] Ti.App.Properties.getObject(property,default);
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | n/a |
Status | Closed |
Resolution | Needs more info |
Resolution Date | 2016-03-30T18:15:01.000+0000 |
Affected Version/s | Appcelerator Studio 4.5.0 |
Fix Version/s | n/a |
Components | n/a |
Labels | feedback |
Reporter | Sean MacLachlan |
Assignee | Shak Hossain |
Created | 2016-03-21T23:02:45.000+0000 |
Updated | 2016-03-30T18:15:01.000+0000 |
Hello, I have tested the following code and got expected result. Default method is not called when property exists. *Code:*
*Console Output*
*Expected Result:* Shows existing property rather than default property when exists . *Actual Result:* Existing property is shown rather than default property when exists. *Environment*: *Device info:* Nexux7 (android 6.0.1) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDKs:* 5.2.0 and 5.1.2.GA *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5 *Appcelerator CLI Version:* 5.2.0 *Appcelerator Studio:* 4.4.0.201511241829
Hello, Can you be a little more specific and explain what you are trying to do and what you are expecting to happen? Please provide a complete test code which you think demonstrate the unexpected behavior. Also please provide the complete steps to follow. Please provide your platform information. Thanks.
var accounts = { // Create a new anonymous user createUser: function createUser(){ Ti.API.log("Creating new user"); accounts.clearCache(); return require('user'); }, loadUser: function loadUser(){ Ti.API.log('accounts.js : loadUser - user cache ' + JSON.stringify(Ti.App.Properties.getObject('user'))); // This should work but create user is being called everytime, not just on undefined Alloy.Globals.user = Ti.App.Properties.getObject('user',accounts.createUser()); }, // Caches user changes and Uploads user settings to Orchestrate updateUser: function updateUser(){ Ti.API.log("accounts.js : updateUser - cache " + JSON.stringify(Alloy.Globals.user)); Ti.App.Properties.setObject('user',Alloy.Globals.user); Ti.API.log('accounts.js : updateUser - user cache ' + JSON.stringify(Ti.App.Properties.getObject('user'))); }, }; module.exports = accounts; My logging shows that I'm calling loadUser and the user object isn't empty but it is calling createUser [INFO] : accounts.js : loadUser - user cache {"location":{"useGPS":false,"city":"Boise","distance":"20.0","address":"Boise, ID, USA","success":true},"userEmail":"",status":"New","accountType":"anonymous"} [INFO] : Creating new user [DEBUG] : Loading: /Users/Sean/Library/Developer/CoreSimulator/Devices/5A3586F1-25C4-4F86-A169-0BB19D1FE96E/data/Containers/Bundle/Application/CF83D2E7-0E59-46DF-A617-3F5CA54B4A93/relevent.app/user.js, Resource: user_js [INFO] : accounts.js : loadUser - loaded {"location":{"distance":20,"city":"Boise","useGPS":false,"address":"Boise, ID"},"userEmail":"",status":"Created","accountType":"anonymous"} Some of the logging and library methods were removed
Hello, The code you have provided has additional components and it isn't clear. Also, you haven't provided the complete steps. Please strip out any code from sample code that does not relate to the bug. Make it as minimalistic as you can. Only add code in order to show the issue, and keep out other things. Please provide a complete test code which you think demonstrate the unexpected behavior. Also please provide the complete steps to follow. Please provide your platform information. Follow the instruction http://docs.appcelerator.com/platform/latest/#!/guide/How_to_Submit_a_Bug_Report-section-29004732_HowtoSubmitaBugReport-CreatingaJIRAticket. Thanks.