I am new to parse.com and react. All of the samples I've seen are based on Flux with actions and stores. ParseReact uses observe() and mutators in the react components. Does this violate the flux model and remove the benefits of encapsulation of the stores? Should I somehow create actions and stores with ParseReact?
ParseReact implements its querying and subscription interface in a similar way to how relay is designed to work with a react component. The advantage is that you get to specify exactly the data each component needs, rather than using a controller view wired to a store which will pass down all data to every component under it. And also similarly to Relay, ParseReact uses a global store so that it can keep every subscription updated in every component across the app.
So if you are just using data from Parse, there doesn't seem to be a need to wire up stores. However, if you are creating local application state from a combination of remote and local data, the flux pattern may still be necessary. For example, maybe you want to have a set of app-wide configuration options. They would likely be set in a settings panel somewhere, and use the flux pattern to change state across the entire app.
Related
Ok, As per my understanding we use middleware in redux for all the async calls now from Apollo documentation we can directly use queries and mutation inside our component.
I personally thought that writing all the business logic in a separate place using middleware is more intuitive as it helps in keeping business logic away from UI (where the data interchange could take place using redux)
Is there any way to keep my business logic separate using redux middleware with GraphQL rather than mixing it in my UI ?
Just like fetch or axios in redux-logic's create-logger.
Is there any way to keep my business logic separate using redux middleware with GraphQL rather than mixing it in my UI ?
You can achieve it by using apollo-fetch with redux-saga which is a Redux middleware.
When there is a need to fetch data, dispatch a simple sync Redux action. It gets intercepted by redux-saga that can use Apollo to fetch the data asynchronously, can perform other async actions in response if needed and then dispatch one or several sync actions to Redux store.
The business logic can then be split between async redux-saga functions called 'sagas' that could trigger other sagas to accomodate more complex logic and finally dispatch action(s) to Redux which remains the main 'source of truth' in your application.
Given that my team is already using graph/Apollo Client, we've recently been moving away from using Redux, and rather opting for Apollo Client's built in solution to manage local state. As noted in its docs:
Apollo Client (>= 2.5) has built-in local state handling capabilities
that allow you to store your local data inside the Apollo cache
alongside your remote data. To access your local data, just query it
with GraphQL. You can even request local and server data within the
same query!
More specifically, using the #client directive, you flag that you would like to fetch the field data locally using either a client-side resolver to execute local queries or mutations, or from the cache. You can take a look at the docs here. The ability to use this single tool has simplified our local state management. More importantly, this solution could meet your request to have more seperation between UI and business logic, as that logic should largely be encapsulated in your client-side resolvers, which can handle async requests, including requests over the network.
I am new to Ember and am used to the MVC model of creating controllers to move data between the view and the server. With Ember, it appears that controllers are support but there is very little documentation on them on the Ember website. From what I can tell, there is an alternative method to save data through the route. Is there an accepted paradigm for how to save data from the front-end to the back-end in Ember?
The Ember guides show you how to use different alternatives.
One easy way is to use Ember data to handle the rest interface with the backend.
Regarding architecture design, you can use the routes or the controllers to interact with you backend using the store.
In our projects we retrieve data in the route, and store it from the controllers.
I'm looking into Volt as an option for building an Admin interface to our REST API. The API is a separate application. I would like the Admin application to persist data to the API but also store it's own data that is irrelevant to the API (such as admin users and notes on the API data objects) locally.
Is there a way to sync each local change in the Admin with our remote API, like a callback, for example? Or do I need to wait until the Data Provider API is ready as mentioned in the most recent Volt blog post (as of writing)?
So this is a fairly common thing, so I think long term the solution will be to support multiple stores in an app and have a REST data provider that you can extend. However that might be a while before that's ready. In the mean time, you can always load and save data via tasks. (I realize its not ideal, but it will work right now) Let me know if you need more info on using tasks to load and save. I'll add the REST data provider to the TODO list.
I wanted to start using breeze js with an existing application. This application already has existing service that expose domain objects that are mapped from entity framework data object.
I wanted to expose these domain objects meta data to breeze so i could use it to track these entities on the client side and save changes. When these changes are saved from breeze I would then work out server side what needed to be done to persist these changes to my data objects.
I've looked at the EF context provider supplied in the breeze samples and was wondering what would be required to create a new context provider that would wrap my domain model ( not DBContext) exposing its metadata and also implement custom saving logic?
Has anyone done this already? Is there pipeline for breeze I've had a look on the user voice site and it looks like Extensible saveOptions and queryOptions are already under review but there is not much detail.
There is a ToDo-NoEF sample provided in the samples zip found here. It shows how to communicate with an arbitrary IQueryable on the server. Is this what you were looking for?
We are in the process of designing/creating restful web services that will be consumed client side using XHR calls from various web pages. These web pages will contain components that will be populated by the data retrieved from the web services.
My question is, is it best to design the return data of the web services to match specifically what the client side components will require for each page? Therefore, only one XHR call will be required to retrieve all the data necessary to populate a specific AJAX component or to update a specific page. Or is it more advisable to develop generic web services, that match for instance a database schema, and will require multiple XHR calls client side to retrieve all the data to populate an AJAX component? The second approach seems to lead to some messy coding to chain calls together to retrieved all the data required before updating an AJAX component.
Hopefully this makes sense.
You should always design services based on what they are to provide. Unless you need a service that retrieves rows from the database, don't create one. You may find you need a service that returns complete business entities - they may be in multiple tables.
Or, you may just need a service to provide data for UI controls. In that case, that's what you should do. You may later find that two operations are returning almost the same data, so you may refactor that into one operation that returns the data for both.
My general rule of thumb is to do what ever is the smallest to transmit over the ajax call. In theory, the more data that is sent to the client the slower the update process. This, of course, would necessarily mean specific services for specific pages.