Sunday, 5 April 2015

Assign object to another variable in Sencha Touch

In Sencha Touch, if we need to assign the Object variable (that contains properties and methods) to another variable, usually developers will write the code as

var obj1 = origObj;

From the above code, both variable obj1 and origObj will point to the same memory location. If we change any properties in obj1, the same will get updated in origObj.

If we need to create a new object from the existing objects,  that will reference to new memory location. Here is the sencha touch code.

var obj1 = Ext.merge({}, origObj);

Now, both obj1 and origObj variable will not point to the same memory location. Here is the documentation reference for Ext.merge().

Hope, you enjoyed this post.

Sencha Touch: How to Integrate BaseUrl for the Ajax request in the Store Proxy URL

I have seen lot of developers hard code the full API URL in their store proxy URL configuration. If they need to change the URL in the future, they need to update in all their stores.  There may be a chance they may leave some store unmodified this will lead to bugs.

We can maintain the baseUrl configuration in a single place, and if they need to change in future, they can change it in once place, instead of modifying in all stores. Let's see the BaseUrl Singleton class which will define the baseUrl of our App which will be used for all the stores ajax request.
Related Posts Plugin for WordPress, Blogger...