Should i use Lawnchair or localForage to maintain data offline - json

I'm writing an app using Ionic framework. I use mongodb as a datastore in the cloud but the lists are too comprehensive and is slowing the app down. After consuming millions of hours reading about client side storage I still dont have a clear answer.
I hoped it would be possible to serve these comprehensive json files native from the client, which is ios + android + windows phone but having not "server" to serve it that idea seemed to be a dud. Dont know if my limited understanding of the rest API in angular is at fault but logically that idea doesn't make sense.
Looking at on native sql clietn I investigated sqlite. Since sqlite implementation on these different platforms(ios + android + windows phone) will be a pain i looked at the different types of browser caching.
I dont want to go into to much detail but localstorage is to simple for my structures, and the other options are not being supported or deprecated. Its a mess. However, the two options regarding offline data solution i have found is Lawnchair and localForage.
What is the differences between these two as they provide the most comprehensive solution based on the client. Any one willing to suggest a beter / worse option.
Then there is the site files which i also want to cache using app cache but I'm not sure how to since I'm using https://www.npmjs.org/package/generator-ionic which is kick-ass by the way.

Lawnchair syntax is a bit more complicated than localForage and the project is no longer updated whereas localForage is (and it's developped by mozilla).
If you are using angular, then go with https://github.com/ocombe/angular-localForage which is my implementation of localForage for Angular, it will be really easy and you can force the driver you want to use if necessary (but on mobile local storage will never be choosen since all mobile smartphones support either websql or indexeddb).

Related

Not sure about the way to approach to the IndexDB API and wrapper libraries?

I have started a crash course of IndexDB API. I have heard from the author that the API is a little bit confusing. Primarily, as we have been working with the promise pattern as this API doesn’t use this pattern. Secondary, there are different wrappers, one of them seems is from Github author’s personal library so I suppose he have created it.
However looking for a different flavor, I found this one: http://dexie.org/. Also supports the Promise pattern. See http://dexie.org/docs/Promise/Promise, http://dexie.org/docs/API-Reference#query-items . It seems “promising”.
Also I found that the IndexDB 2.0 API was created post the video time. It is already being supported since beginning of 2017. From a Mozilla developer, I found since Firefox 51 (Jan 2017) it is already there. And he wrote what’s the differences among 1 and 2 versions https://hacks.mozilla.org/2016/10/whats-new-in-indexeddb-2-0/
So my question is if at this point is better to use the wrapper libraries or to use the native IndexDB API in terms of cross-browsing and support and better practices?
It all depends on what you want to do with indexeddb -
If you are learning indexeddb for your interest or for knowledge then you should go for plain indexeddb. Learn and research as much you can, because it has too many apis and you will have to write code for every type of situation.
You want to use indexeddb in your project and dont have much time to explore indexeddb. You only want to do some database operations and release your project. In this case - you should go for indexedd library. This way you dont need to worry about indexeddb code . You will just write simple code using the library.
For instance : check out this article - https://dzone.com/articles/crud-operation-in-indexeddb-using-jsstore. How a library makes indexeddb so easy.
Hope this will help you.

Flex realtime polyfill

I'm developing a service in flex which requires realtime invalidations and I was wondering which is the recommended method to add realtime support to Flex applications (any change to data models should be reflected to all subscribed clients).
Here are some concerns:
My server is written in python3 (tornado, sqlalchemy, redis) although I don't care adding another service written in other language as long at it is simple and not a resource hog (no java please :)). My client is written in Flex and this must be supported
I want to have multiple servers\processes to handle realtime
connections and I don't want to use sticky sessions (SPOF?). All of the processes will be behind a Load Balancer.
I don't
care about the transport method as long as it is not proprietary (no RTMP), it has fallbacks and it is well supported (mostly IE9 and above)
Currently, I use Tornadio2 and FlashSocket.IO but both are not maintained and not recommended.
I thought about using SockJS though It doesn't have Flex support (can I use it through the browser?), and it seems that beside FlashSocket.IO, there are no other libraries available. It should also be noted that this library doesn't have fallback capabilities.
During my research, I saw several relevant questions:
Real-Time communication between PHP and Flex application
Realtime update and Push Data in AS3
But they are 4 years old, and doesn't provide a good answer.
Any thoughts on the subject would be appreciated.
It seems that this topic is not hot (to say the least), but in case someone is interested, I managed to get around it by using SockJS on the flex html wrapper and communicating with it using external interface
I am doing something similar in Flex by using WebSockets (sockets.io) on the serverside. On the client side, I am using the AS3WebSockets library from https://github.com/theturtle32/AS3WebSocket
Works exceedingly well!

application design: Scala + HTML5

I'd like to implement an application with Scala and HTML5. My idea was to create a "local" client-server architecture: Scala handles the calculations and generates HTML5 as a GUI.
To my mind there are two possibilities
Use a Java/Scala framework that allows embedded HTML5. SWT for example has a browser widget. JavaFX seems good, too.
Distribute the program with a server and run it in a browser on localhost.
It would probably be most convenient to require an internet connection and forget about the localhost. Unfortunately an offline mode is necessary.
Now I would like to know how to get this right:
The first option seems easier to implement but I wonder: How can I communicate with Javascript without the HTTP protocol ?
The second approach was just an idea. Have you ever done something like this ?
If you've got advice or know a good framework please go ahead.
UPDATE :
I've just had an interesting idea: Could I use nodejs to create something like a server-server architecture ?
Right now the communication between Scala and Coffescript seems like the most problematic part. I still wonder how I could initiate an update from the Scala side of the application. A HTTP Request is a nice way to exchange data. Sadly to my knowledge in "standard" Coffeescript there would be no event hook to listen to server-side HTTP messages.
I've thought about using nodejs to listen to the server-sent data. Is this a good idea ?
With regards to the second option, you may wish to investigate the Play! Framework or Lift. They automate a lot of the work required to make a web application in Scala, including handling AJAX requests.
Although I haven't tried packaging either for local use, there was an earlier Stack Exchange question about packaging Lift which might be relevant. It should be possible with Play! as well.

What to Use for PhoneGap Database Storage

I am writing an application using PhoneGap, and am finding it hard to work out how to store my data in a database. For the minute I just want to keep an open mind as I will be recommending technology options to our company.
The PhoneGap API for storage is here,
http://docs.phonegap.com/en/1.3.0/phonegap_storage_storage.md.html#Storage
It is based on this HTML5 spec,
http://www.w3.org/TR/webdatabase/
The problem for me is that the specification for this is not being maintained any more, and the standard has been deprecated.
The other problem is that I implemented a database using web database, and the versioning didn't work properly.
What is PhoneGaps stance on this and will PhoneGap look at other technologies such as the Indexed Database API,
http://www.w3.org/TR/IndexedDB/#database-concept
I am storing JSON data in the localStorage for now which is working great, but I am wondering if my database could get too big and it might not be the best option.
I faced the similar issue while developing an application few months back in which we were expecting to port the application to different platforms (with different versions). So instead of using the core storage mechanism which phonegap offers we went on using a dedicated storage framework which can provide consistent api but uses the best underlying storage mechanism.
There are variety of JS frameworks which can help you use the underlying storage. The following are few might interest you if you are planning to use the app on different platforms.
PersistenceJS - persistencejs.org
lawnchair - http://westcoastlogic.com/lawnchair/
persistencejs uses gears and localstorage in combination which helps to run the app on BlackBerry 5.x devices as well without any change.
I went on using the persistencejs and it have really worked well till now. We have ported the application on Android, iPhone, iPad, BlackBerry (5.x and greater)

How to use persistenceJS in phonegap application?

We are building a field data collection tool that will be available in two versions:
Fully html5 -- directly
downloadable through your browser
(does not support camera access,
etc..).
Hybrid using phonegap --
installation required (does support
camera access, etc..).
In the html5 version we are using
persistenceJS to store data. Somehow this does not seem to work in the hybrid version and it would be nice to keep the code base as generic as possible.
Does anyone know about using persistenceJS in combination with phonegap?
Note 2011/04/04: In a prototype we have gotten persistenceJS to work in phoneGap. Probably some kind of library is interfering in some way.
Phonegap is kind to persistencejs.
The only potential trouble is with iOS, which made its websql storage non-persitent starting in iOS 5. In other words your database can be periodically removed by the operating system.
If you upgrade to Phonegap 1.6 and up, there is a built-in fix for this problem and your persistencejs will work just fine.