I'm trying to integrate breeze.js on my SPA .
Working with in with the entity structure comming from the DB is really straightforward.
I have a problem when I need to deal with special cases. Here is my case :
I need to get my entity list , in the first time I fill the entity from external source only for display mode (the original data exists in an external source) , when I see the data then I can choose which to approve, then I'll save the entities in my DB.
Do you know to manage this with breeze in automatic way .
Thank in advance ...
Take a look at the NoDB sample in the Breeze zip.
Related
I am starting a new project (learning purposes) and I am trying to figure out what is the best software design pattern to use in the following scenario.
I have several data that need to be downloaded from multiple webservices and store somewhere in my app, to display it later. However each piece of data (e.g. list of teachers, students) will only be used in one or more specific view controllers (e.g. teachersViewController and studentsViewController).
I read that the Singleton pattern or use the AppDelegate to store a variable (an object like ApplicationData) is a bad practise, even more in this example which I want to restrict the data access.
So, which design pattern should I choose? I have read something about dependency injection, but I don't have any clue about it or if it even helps me in this question. If it helps, some examples with explanation would be nice.
You need some sort of database to store downloaded data. Good choices are Realm and Core Data. The right way to process data is:
Check if data is already in DB and show it if available.
Download or update data from server and parse it to objects.
Save objects to DB.
Show data taken from DB to user.
Download data as needed. When you open VC with students then download only students data and so on.
EDITED: If you need all the data on app open then load it and put in a DB before first screen opens. Then just use DB to show data to user.
I am trying to implement Core data for the first time . I got to know about the MagicalRecords and RESTKit while learning about the core data. i am right now in a fix about how to implement Core data and how to use both the libraries in the same application . And is it safe and best way to use both .
In RESTKit , it need endpoints for mapping . What if i have more then one endpoints for single Entity.
How i cam be assured that i will not have duplicate data in the application.
Right now i am having request on each and every UIViewController . Fetching JSON in UIViewController itself and dumping it in Arrays .
How can i reduce the calls , use application without network. Please enlighten me with the knowledge about this .
Before down voting please comment what you are not understanding. Thanks
And is it safe and best way to use both .
Safe is all about you code and how you write it. You don't need to use MR & RK together but you can - both are conveniences to help you.
What if i have more then one endpoints for single Entity.
Create multiple request / response descriptors
How i cam be assured that i will not have duplicate data in the application.
Use core data and unique identities. Consider also using a shared data controller rather then redefining everything in each view controller.
How can i reduce the calls , use application without network.
You need to design your own scheme. Core data will help as you can run fetch requests to get existing data and make a request to update, if you use a fetched results controller it will automatically update with the results.
In SPA , how can we use BreezeJS to save data on client cache before saving back to database. I am working on this HotTowel Template and trying an application which is a simple calculator and I want to calculate the results using cache and save it to only cache (client browser), and I should be able to query on the results. ( I am already done with this type of application but problem is that it will do the saveChanges into database directly and the view is updated accordingly)
It's not clear that you have a specific issue we can address.
For a general understanding of how to manage changes offline, you might watch John Papa's Pluralsight course, "Building Apps with Angular and Breeze - Part 2", particularly the "Saving State with Local Storage" module.
app scenario: on the UI, a button is tapped to get contact list from the server. the request goes to subproject which does the download and parsing and returns the result thru its delegate to the UI. so far everything works properly. lets say there is no internet connection and we cant have the contact list. to solve the problem, I want to cache the data in core data. if there is no internet, the cached data will be returned. now the question that bugs me, is it possible to create one data model and use it in subproject to save the data and in UI where data get pulled and edit from the same data model?
so basically i want to access core data from different subprojects and UI.
i couldnt find hints or tutorials regarding this issue. any ideas?
thanks in advance!
edit:
a project "b" that is added to the parent project "a". the project "b" is actually a static library.
if i let the library to do the saving and returning data to UI, wont it be inefficient to get all data from core data then send it to the UI?
i actually hope that there is a way to use same data model in both UI and the library.
i want prevent the UI to have huge load of data. its better to hace core data to handle that incl. memory mangement. i'm still reading some sources and trying to implement it on a test project.
I would argue that only the main project should deal with persistency, as than you can always decide to handle it differently — save it permanently or not, use core data or a home grown sql wrapper…. So it would be up the the delegate to decide what to do with more data.
But along with the delegate protocol you could decide to maintain different model protocols that define, what your models can hold. this would be independent to the implementation. The delegate now could return objects — no matter if core data models or not — to the delegator if this objects conforms to the protocols. The delegator in the sub module now could check for values on the server and/or in the cache.
My situation is that i have an external database and i should present the information in an orchard hp. The customer wants also to set new information and both should be shown via projection.
Short with simple example type book:
Books are in an external db.
Books should be set in orchard, in the orchard-db not in the external-db.
The query - projection should get both books-entities and displayed.
Is there a simple orchard-way to implement my problem?
Unfortunately, I did not find any sample for what ... Any suggestions?
Thank you
From what you've described I understand that in short you want to manage some data from an external data source as Orchard content items. This is well possible, it needs the following to happen:
Create a content type for your data.
Periodically pull in changes from the external data source.
Programmatically create content items of your new type from the data pulled in.
Since this is not an everyday scenario I don't know of any tutorials out there for this although there is at least one sample: the External Pages module does pretty much this, by pulling in Markdown pages from a Mercurial repo.