Sencha Touch: Store without proxy - sencha-touch-2

I have been wandering on the internet for a basic question regarding Sencha Touch Stores.
The question is , If we don't use any proxy like WebSQL, localstorage etc for the store then where is the data stored? Or Where can we view the data?
Elaboration Of My question
I have created a store like this.
Ext.define('MyApp.store.UserPass',{
extend: 'Ext.data.Store',
config:{
model:'MyApp.model.UP',
storeId:'UserPasswords',
//no proxy
}
});
At runtime , I add some data in the store using
Ext.getStore('UserPass').add({param1 : "data1" , param2 : "data2"});
Then I binds this store to a List. Everything works fine.
But the question is where is the data stored w.r.t to storage i.e in program's memory, browser's memory, nowhere or somewhere?
May be It looks like a silly question, but the answer of it would help me in understanding a lot of related concepts.

If you don't specify a proxy for your store, the proxy will default to Ext.data.proxy.Memory. Take a look at the code of the applyProxy method of Ext.data.Store. So there will never be a store without a proxy.

Related

Ember change normalizeResponse based on queried model

I'm using a second datastore with my Ember app, so I can communicate with a separate external API. I have no control over this API.
With a DS.JSONSerializer I can add some missing properties like id:
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
if (requestType == 'query') {
payload.forEach(function(el, index) {
payload[index].id = index
})
}
Now I can do some different tricks for each different requestType. But every response is parsed. Now sometimes a response from one request needs to be parsed differently.
So what I am trying to do is change the normalizeResponse functionality for each different request path (mapped to a fake model using pathForType in an adapter for this store). But the argument store is always the same (obviously) and the argument promaryModelClass is always "unknown mixin" - not sure if this can be any help.
How can I find what model was requested? With this information I could do a switch() in normalizeResponse.
Is there a different way to achieve my goal that does not require me to make a separate adapter for every path/model?
There are over a dozen normalize functions available. Something should work for what I am trying to achieve.
I think this is a great example of a use case of not using ember data.
Assuming that you have models A,B,C that are all working great with ember data, leave those alone.
I'd create a separate service and make raw requests to that different endpoint. So you'd replace this.store.query('thing', {args}) with a separate service that uses ember-ajax (or ember-fetch or whatever). If you need, you can use that service to hold the data that you need (Ember-data is just a service anyway) or you can create models and push them into the store manually.
Without knowing more about your exact situation, hard to give a specific code/advice, but I'd just avoid this problem and write your own custom service.
You can use primaryModelClass.modelName.

Relay modern caching example

I would like to enable caching in my react native application. I am using GraphQL with Relay modern. I found out that caching is not enabled by default in relay modern, but they have exposed RelayQueryResponseCache from relay-runtime, which we can add to the fetchQuery function in our API. I read discussion here and here about it, but have not seen any example to get started. Can someone help me out on this?
EDIT:
Ok I came up with a solution. I think it misses few things but so far it serves our needs.
I have noticed that passing anything into QueryRenderer into cacheConfig results passing that value into fetchQuery function inside my environment.
So I have created a Component which loads the data by some relation and resolves it into the correct json structure requested by the query. Then I return this into the state. Then I extended my Component which contains QueryRenderer with the created 'cache loader'. Now when componentWillMount() is called I ask for the cached data. During this I have set this.state.loading = true so I am able to handle loading state. Reading from DB is async.
I am using this class in other components as well. Every one handles its cache data. I just pass it to QueryRenderer.
However I was thinking that this makes some extra logic need to add for each Component which is supported by this caching. Probably passing the cache resolver as cacheConfig and resolve the cached data immediately inside the environment would be much more cleaner.

How to pass data between Different Pages in Windows Phone 8.1

Passing Data from Page to Page for Windows Phone 8.1
i found this great article :
http://www.windowsapptutorials.com/windows-phone/how-to-pass-data-between-different-pages-in-windows-phone-application/
and i understood it very well,
there are few question i came after reading this article is :
[1] which method is better, in which scenarios ?
[2] what is the benefits of all 3 methods?
Small hint: Please state if you are using Silverlight or WinRT, as it makes a big difference.
I assume you are using Silverlight here.
Like demas already stated: Global variables are almost never a good idea.
Recommendation: Always use queryString and always only pass IDs in the query.
This means, keep your data in some kind of storage and always read it from there on any page.
If you want to pass complex objects, put them to your storage, tell the new page the id and on the new page load it from the storage.
If your app gets terminated (tombstoned) in the background and is
relaunched on your detail-pages, it may always be that your global
variables are empty.
It also improves your maintainability: All data accessed by a page will be loaded on that pages code/codebehind/viewmodel; You don't have to check other parts of the app to find out where that data comes from.
Further hint:
It helped me a lot, to think of a Silverlight app like a "web app": The pages are individual pages and the viemodels are the database servers. There is no way to pass data between these pages other than the query string.
Public property in App.xaml.cs and global variables causes namespace pollution and make the application less testable, so I prefer to use QueryString.
On the other hand, sometimes I need to pass complex object or even collections of complex objects and in this case public property in App.xaml.cs is more preferable in my opinion.

How to get mapserver to work

I've been working with MapServer for about 2 hours now , but it seems alittle bit complicated to get started with.
So here's my question
Is there any way to get mapserver to show a simple map of whole world in which I can move the map to see different parts of the world ?
( from what I've learnt so far , it just shows you the Map you've passed the mapserv cgi , and the map is static and cannot be moved ! )
EDIT :
I'm still wondering if I can have a simple map for the whole world or a country or whatever ! Should I be Writing .Map Files for everything On my own ??
Okay , so after looking it up and struggling alittle , I found some JS libraries to do this, One of the was Open Layers. You just have to reference it at the beginning of your html page like :
<script src="http://openlayers.org/api/OpenLayers.js"></script>
and then you can have zoom and move options for your map by binding MapServer data as follows to the OpenLayers init function.
Var map, layer;
function init(){
map = new OpenLayers.Map( 'map' );
layer = new OpenLayers.Layer.MapServer( "NAME",
"http://localhost/cgi-bin/mapserv", {map: 'PATH_TO_.MAP'} );
map.addLayer(layer);
map.zoomToMaxExtent();
}
And lots of cool tutorials can be found in spatialhorizons.com.
Hope this helps someone :)
MapServer is just that, a MAP SERVER. It sounds like you are currently using a cgi script to display a hosted map. WMS providers like MapServer host data that can be viewed using a WMS client application. There are many such applications. You will need a more sophisticated client application to connect to the MapServer in order to perform more complicated map manipulations.
check out GoogleEarth
or NASA WorldWind
or I haven't used this yet but it looks like it might be the easiest, if least dependable.
First MapServer is the GIS server side technology. The zoom in/ pan is the client side behavior in my opinion.
When we look at the moment that user pan/zoom at one web application, what really happened is the front end application get the pan/zoom event and make calls to mapserver to get the new map to return to the client side.
So it is more likely your leaflet, Google map API, Openlayers, etc. are handling the detection of the client movement and parse it into new getmap request and send the request to mapserver to get the response.
What you saw from the MapServer using get request is static and it is suppose to be so. The dynamic part is happened in the client side to make dynamic calls from the front end application to make these static calls. That is interactive when client side dynamically sending out request and refresh the map from the response.

How can i get data from server in sencha touch

I am new to sencha touch can any one help me, what is the way to get data from server. I didn't understand clearly. Please help me. In need to display the values from server to grid. I dont how to do that.Now I have added the values directly to grid store.
You should dive deeper into two aspects of Sencha Touch: models and stores. A model is simply a representation of an object. For example, you could define 'User' as a model with the fields 'id', 'username', 'email'. Stores can be seen as collections of model-objects.
The beauty of Sencha is that the models / stores can be given a proxy parameter. There are various proxies available, but you should choose the one that suits application the best. For example, the AjaxProxy sends a request to the server to load the data. Once your store is loaded (please not that AJAX calls are made asynchronous) you can populate it in for exampe a List or NestedList.
Some example code, directly taken from the docs:
Ext.regModel('User', {
fields: ['id', 'name', 'email']
});
//The Store contains the AjaxProxy as an inline configuration
var store = new Ext.data.Store({
model: 'User',
proxy: {
type: 'ajax',
url : 'users.json'
}
});
store.load();
you can use this tutorial.
it's very useful
http://programmersgoodies.com/how-to-parse-xml-response-with-sencha-touch#comment-27
Download the SDK of sencha touch2 and then you can refer example which is present in sencha sdk for using the servers. This is important to use web services for getting data from servers.
Just refer to the below link.
sencha-touch-2.0.1.1\examples\ajax