How do you handle complex JavaScript objects on the client?

EDIT: I'm going to break this down into two more specific questions.

I am trying to understand best practices and patterns for client-side JavaScript development. In particular, what do you do to manage more complex data models on the client?

As an example, let's say that you manage some kind of network directory on the Internet and have a Product with its rather typical properties: {id, description, price, etc.}. But the product also has a set of categories with which it could be associated, and therefore, it was necessary to select two more lists: AvailableCategories and AssociatedCategories. Of course, to make things more complex, your association of categories with tables is not a simple join, but has metadata, such as a scalar number from 1 to 10, which describes how strongly the product is associated with the category. And then let's say that there are four or five other associations, one of which has an “Available” table, which may require swapping (for example, maybe you associate a product with something that has a million items in the table,and you want to collapse only 100 of them at a time, with the ability to search and sort, of course).

My point is that there are many models, as well as the association of associations with meta-information, some data can be pre-loaded or statically loaded to load the page, while some of them must be dynamically loaded. And, of course, you just don’t need basic models, but also “observable” ones, so if someone chooses a color to communicate with your product, you will be notified (for free) elsewhere on the change page.

I'm going to upgrade to the client side MVC platform like SproutCore, but would like to see some lighter weight options and templates. I would appreciate that you use, why you use it, and any other thoughts on this problem space.

Thank.

+3
4

javascript-, , , . , RPC ajax, , . , RPC ajax, , .

RPC, , , , , .

, , , , .., , javascript-, .

MVP , MVC - .

+1

, , , :

, . , . , , .

. ( YUI ajax- )

0

, . JSON - ?

Ruby on Rails : js.erb. AJAX js js.erb, Rails, .. javascript, Rails, erb:

<%= @object.attribute %>

0

MVC- , SproutCore, .

Sammy.js is fantastic if you want something easy. I am in the middle of writing a one-page web application (80% done). It gets / sets all its data from a RESTful web service based on ~ 30 tables and a bunch of “views”. I am stunned by how easy it has been so far, and Sammy certainly helps a lot.

0
source

Source: https://habr.com/ru/post/1777705/


All Articles