I am planning to use Sencha Touch for an application of my company. I read that local storage stores data on client's browser. MY problem is when I build the code to native app using Sencha CMD how does the local storage work? What is the alternative of local storage to keep some data suppose user details (so that user doesn't need to login always).
Advance Thanks
localStorage
Is a very easy to use interface that works synchronous. It stores strings (you can JSON.stringify other Javascript objects) as key-value pairs and you just set the value with a key in this way:
localStorage.setItem('key', 'value');
To read:
var value = localStorage.getItem('key');
which returns value or null if key wasn't found in the storage.
You can use it as an object:
localStorage['key'] = 'value';
var value = localStorage['key'];
however, this is not the recommended approach. In this case undefined will be returned for non-existing items.
More details:
http://www.w3.org/TR/2013/PR-webstorage-20130409/
http://diveintohtml5.info/storage.html
IndexedDB
Database that sort of replaces the now deprecated Web SQL. It works asynchronous and is a bit harder to understand as it uses stores, requests and transactions to deal with the data.
You can store any kind of objects in IndexedDB (Javascript objects, Blobs (files)).
You can also request storage space. User will be alerted if you need more than 5 mb (5 mb is not defined, but seem to be the limit most browsers set before asking user for permission).
See here for details on how you can use it:
http://www.w3.org/TR/IndexedDB/
http://www.html5rocks.com/en/tutorials/indexeddb/todo/
Web SQL
Although, as mentioned, deprecated it is still supported in browsers such as Safari. Is a database that works with SQL-queries and request, and works asynchronous.
Here are more details:
http://www.w3.org/TR/webdatabase/
http://html5doctor.com/introducing-web-sql-databases/
File API
Currently only supported in Chrome. Is a virtual file-system that works asynchronous as IndexedDB but is intended for large files (video and audio files etc.) but can just as easily be used for storing other data.
You can store any kind of objects in File API as Blobs (files). As it is a virtual file system you can navigate using folders.
You can also request storage space here as well (quota).
For details:
http://www.html5rocks.com/en/tutorials/file/dndfiles/
http://www.w3.org/TR/FileAPI/
And of course there is cookies and for IE UserData, but these are very limited.
This example demonstrates how to use local storage with Sencha Touch model objects:
http://www.mysamplecode.com/2012/06/sencha-touch-local-storage-example.html
If you're wanting to switch & sync data from online to offline you might also be interested in this example:
https://www.robertkehoe.com/2012/11/sencha-touch-2-localstorage-example/
Related
I'm injecting the adrum script cdn.appdynamics.com/adrum/adrum-21.2.0.3385.js in my Vue application to collect data about it.
It's working correctly, but I don't see any functionality to send specific logs to AppDynamics.
I'd like to have, in my typescripts files, some kind of function that I could use to send string logs and being able to read them within AppDynamics. Is that possible? In that case, where should I look for those logs in AppDynamics?
Try sending it as custom user data, but a size limit is associated (of 2048 characters). It works for XHRs, Base pages, iframes, and Virtual pages. Data can be seen in the Controller UI under both Analytics and Browser Snapshots.
Documentation: https://docs.appdynamics.com/appd/22.x/latest/en/end-user-monitoring/browser-monitoring/browser-real-user-monitoring/configure-the-javascript-agent/add-custom-user-data-to-a-page-browser-snapshot
I have a vue3-app that serves as the frontend of an asp.net core 2 api.
Much of the requested data gets used by multiple components. And in order not to make multiple identical requests, i want to store the response-data in my vuex-store if it's not in there already.
The problem is, that most of that data changes a lot, so i need to be able to tell vuex to refresh the data after some time.
But i don't want to refresh all of the requested data, since some of it doesn't need to be refreshed as often and some not at all (for example a list of countries).
So what I need is a way to tell vuex wheter i want to save the response of a specific axios request forever, or to re-request it after a set amount of time.
My questions are: Is there a plugin for this that I couldn't find? And if not, how could i implement the described functionality without rewriting it for every request?
There are some axios cache projects available:
axios-extensions (LRUCache)
axios-cache-adapter (localforage)
cachios (node-cache)
The 2 most popular currently are axios-extensions and axios-cache-adapter
Source of the chart
There is a library axios-cache-adapter that is a plugin for axios, to allow caching responses.
It is a great solution for implementing caching layer that takes care of validating cache outside of application's data storage logic and leverages it to requets library instead.
It can be used with both localstorage and indexedDB (via localforage library)
I'm about to create an application that uses JSON to update its content.
This is how I planned it to work:
When application starts, it checks (with internet connection is available) if the JSON file set on remote server is newer than the one stored localy - if it is then it's downloaded.
Then, the application applies data from that JSON to the content. For example, to the "Contact" information - it applies data like phone numbers etc.
My question is, is it in your opinion, a good technique to update appliactions content?
Does anynone had an experience with building app with this kind of idea?
Best regards,
Zin
Of course you can do this. One thing that may lead to a better user experience would be to ask the user for his permission to download new content (if there is something new).
This is a normal thing to do. I have a phonebook app that does exactly this. On a side note, if you need a network class to handle the web-service interaction, see this SO post. I wrote a custom network class that works with AFNetworking.
I'm writing an obj-c app and would like to upload a binary file a few megs in size to my appengine server (python). I'm guessing I need to use the blob entity for this, but am unsure how to go about doing this. I've been using http requests and responses to send and receive data up to now, but they've been encoded in strings. Can someone advise how I'd go about doing the same with blobs from an obj-c app? I see some examples that involve http requests but they seem geared toward web page and I'm not terribly familiar with it. Are there any decent tutorials or walkthroughs perhaps?
I'm basically not completely sure, if I'm supposed to encode it into the http request and send it back through the response, how to get the binary data into the http string from the client and how to send it back properly from the server when downloading my binary data. I'm thinking perhaps the approach has to be totally different from what I'm used to with encoding values into my request in the param1=val¶m2=val2 style format but uncertain.
Should I be using the blobstore service for this? One important note is that I've heard there is a 1 meg limit on blobs, but I have audio files 2-3 megs in size that I need to store (at the very least 1.8 megs).
I recently had to do something similar, though it was binary data over a socket connection. To the client using XML, to the server as a data stream. I ended up base64 encoding the binary data when sending it back and forth. It's a bit wordy but especially on the client side it made things easier to deal with, no special characters to worry about in my XML. I then translated it with NSData into a real binary format. I used this code to do the encoding and decoding, search for "cyrus" to find the snippet I used, there are a few that would work here.
In your case I would change your http request to a post data call rather than putting it all in the URL. If you're not sure what the difference is, have a look here.
I'm not as familiar with python, but you could try here for help on that end.
Hope that helps.
Edit - it looks like blobs are the way to go. Have a look at this link for the string/blob type as well as this link for more info on working with the blob.
There are three questions in one here:
Should you use a BLOB for binary data?
How do you post binary data, and use it from app engine
How do you retrieve binary data from app engine
I can't answer if you "should" use blobs, only you would know the answer to that, and it greatly depends upon the type of data you are trying to store, and how it will be used. Let's take an image for example (which is probably the most popular use case for this). You want users to take a photo with their phone, upload it, and then share it with other users. That's a good use of blobs, but as #slycrel suggests you'll run into limitations on record size. This can be workable, for example you could use the python image library (pil) to downsize the image.
To post binary data, see this question. It would be best to cache 2 copies, a thumbnail and a full size. This way the resizing only has to happen once, on upload. If you want to go one better, you can use the new background jobs feature of app engine to queue up the image processing for later. Either way, you'll want to return the ID of the newly created blob so you can reference it from the device without an additional http request.
To retrieve data, I think the best approach would be to treat the BLOB as it's own resource. Adjust your routes such that any given blob has a unique URL:
http://myweb/images/(thumbnail|fullsize)/<blobid>.(jpg|png|gif)
Where BLOBID is dynamic, and JPG, PNG or GIF could be used to get the particular type of image. Thumbnail or fullsize could be used to retrieve the smaller or larger version you saved when they posted it.
So, I have a bunch of HTML is being stored in a SQLite database, and they link back and forth amongst themselves. When a user clicks to follow a link, that request needs to be serviced by pulling the appropriate HTML out of the database. This could result in needing to load images, which are also being stored in the database (this is a future thing; there are no images yet, but I'd like to be able to use them). I've looked through the WebKit documentation, but can't quite figure out how to make this happen. I've mostly looked at WebFrameLoadDelegate and WebResourceLoadDelegate, but I didn't see one that would let me catch the request, grab the appropriate content, and then send that in a response.
Ideas? I'm pretty new to Objective-C and Cocoa, but I think I'm mostly getting the hang of things.
How do the pages which are stored in the database link to each other? It is probably easiest if they use some sort of customer URL scheme to start with.
The approach I would use is to implement
-webView:resource:willSendRequest:redirectResponse:fromDataSource:
in your resource load delegate. If the request is for a resource that is actually located in your database, return a new[1] NSURLRequest which uses a custom URL protocol which points to the database resource:
x-my-scheme:///table/row
[1] Unless you are already linking amongst your resources with the custom URL scheme - then you can skip this step.
Then, implement a custom NSURLProtocol for x-my-scheme which knows how to retrieve the data from the database. The PictureBrowser sample gives a simple example of how this is done.