Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$resource #86

Closed
tabdurman opened this issue Oct 11, 2014 · 5 comments
Closed

$resource #86

tabdurman opened this issue Oct 11, 2014 · 5 comments
Labels

Comments

@tabdurman
Copy link

No word on using $resource! They made it easy to access repositories, but we heard nothing about that!

@johnpapa
Copy link
Owner

$resource is great, but this is a style guide. What type of style would you like to see in regards to it?

@tabdurman
Copy link
Author

I will say somewhere in Data Services, but you are right, I forgot for
minute it just a style guide.
Maybe it is because I never use $http but $resource in repository pattern
way - to access data, so it looked little odd for me to see $http reference
there.
Great guide overall, and great courses on Pluralsight, thank you!

On Fri, Oct 10, 2014 at 9:47 PM, John Papa notifications@github.com wrote:

$resource is great, but this is a style guide. What type of style would
you like to see in regards to it?


Reply to this email directly or view it on GitHub
#86 (comment)
.

@johnpapa
Copy link
Owner

No worries. There are a lot of tips like this I think are useful. If anything, when you add them to issues like this other people will discover them. But I am compiling a list of these and finding a good place to host them too. Stay tuned :)

@sbrouil
Copy link

sbrouil commented Jun 15, 2015

Opening an old post, I hope you would respond anyway.
Using $resource as data service may lead to style questions.

The easy way (convention ?) to use $resource is to define one factory by resource URI, for instance :

  .factory('Dashboards', ['$resource', function ($resource) {
    return $resource('/dashboards/:id');
  }])
...
  .factory('Users', ['$resource', function ($resource) {
    return $resource('/users/:id');
  }])

creating the following files :
dashboards.factory.js
users.factory.js

In your styleguide, you recommend to put data services in a single service "data.service.js". Does it still apply if I use the "$resource as data service" style ?
*If not : *
What is the naming (service and file name) to choose to distinguish a "Dashboards" service that encapsulate the business logic part of the "DashboardsController" and the "Dashboards" data service ?

@ruionwriting
Copy link

@sylvain-brouillat in my case I've decided to have all my data services on a 'data' module and for each context I have .dataservice.js. The reason I do this is because each context contains a lot of operations and feels more cleaner to separate them. Does this naming sounds good to you?

Also this makes all my jasmine tests a lot more organized and clear. Basically I fallow the same logical tree to organize them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants