javascript - Where to format collections / objects -


from front end architectural point of view, common way store scripts perform transformations on collections of objects/models? in folder store it, , name file / function?

currently have models, views, controllers, repositories, presenters, components , services. expect it?
component (what name it?)? service? use services make connection between presenter , repository handle data interactions server.

should call formatter? transformer? if there common way do, i'd know it.

[...] models, views, controllers, repositories, presenters, components , services. expect it?

services, mos def. interception service parsing data.

should call formatter? transformer?

well, trasformer (or data transformer) quite imo. data interceptor comes mind, , data parser, obviously.

if there common way do, i'd know it.

yes, there is! override model's / collection's parse() function transform data fetched server preferred data structure.
note should pass {parse: true} in options make work.

this, of course, not contradict using services wrote within function. can encapsulate parsing logic in scripts, , reuse anywhere you'd like.

bare in mind there little code reuse when using parse(), each transformation relate single model or collection.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

Kivy: Swiping (Carousel & ScreenManager) -

jdbc - Not able to establish database connection in eclipse -