Hi,

But using this approach my service needs to have all the data. My program
has a large data set on the server backend, so fetching all data is no
solution. The service also can't really save new items when they are first
requested and so build its own local memory over time because of the start
and end parameter. Lets say some items get deleted then its really hard to
keep track of which start and end to call for or check if they are already
fetched.

Some use case examples:
* directive 1 requests item 1 - 500
* directive 2 requests item 15634
* directive 3 requests all items with name=*test
* directive 4 requests item 1 - 500

So directive 1 and 4 basically use the same data and it would be good if
they would synchronize, so if directive 1 changes the data then 4 notices
it and vice versa. The service can't save all data and there can be a large
variant of requests for items like in directive 3.

That all is no problem currently because my list controller fetches the
data needed, like data for 1 and 4 and passes them to the directives.
Because the same object is passed to both directives and they use two way
binding the data is always synchronized. I just don't see any solution
achiving this when each directive should fetch the data directly with the
service.

2014-12-03 19:29 GMT+01:00 Sander Elias <[email protected]>:

> Hi André
>
> Well, if your directives use separate pieces of data, the syncing isn’t a
> issue to begin with, and keeping the state out of the data is enough right?
> Otherwise make sure the service takes care of the syncing. Keep the cache
> in the service, and hand out references in stead of copies.
> You can do something like myService.getData({start:1, end:10}) and so on.
>
> Regards
> Sander
> ​
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/FWYpwl_H6t0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to