NG6-starter icon indicating copy to clipboard operation
NG6-starter copied to clipboard

We should add an example of service

Open iranreyes opened this issue 9 years ago • 17 comments

iranreyes avatar Nov 23 '15 20:11 iranreyes

@iranreyes can you make a pull-request of a simple one?

PatrickJS avatar Nov 23 '15 20:11 PatrickJS

ok :+1:

iranreyes avatar Nov 23 '15 20:11 iranreyes

@iranreyes I'm still wrapping my head around the componentized approach so bear with me. Will service be at the component level in this case or more at the core level to be shared across components?

adyngom avatar Dec 04 '15 19:12 adyngom

@adyngom Mainly depend of the responsibility of the service, if the service is just for the component will be inside it. This is very common because the goal is develop with OOP and SoC, so you should not write many logic in your controllers. And if the services are more general, are located in the core. You can see them like a layer, for example data access layer, UI sync layer, etc

iranreyes avatar Dec 04 '15 19:12 iranreyes

@iranreyes :100: makes sense - it would be great to see then how a core service such as login, authentication and such will fit and be accessed in this structure. The component based service might be pretty straightforward and maybe extending the generator to have it part of the default files would be a great add as well.

adyngom avatar Dec 04 '15 19:12 adyngom

Login could be a module too, a set of components and service that you can use in your app. Imagine like a reusable module....

iranreyes avatar Dec 04 '15 20:12 iranreyes

@gdi2290 I can't do pull-request because I don't have permissions. I have tried with several but without success.

iranreyes avatar Dec 04 '15 20:12 iranreyes

Ok so after taking a closer look doesn't the 'user' module that is provided in the app boilerplate satisfy both use cases of having a component service, and that same module can easily be imported and used on other modules that need it?

adyngom avatar Dec 04 '15 20:12 adyngom

@iranreyes want to pair on it tomorrow via google hangout?

PatrickJS avatar Dec 05 '15 01:12 PatrickJS

@gdi2290 Hi, yes we can do it tomorrow, I am available almost all day, but between 11am - 4pm it is perfect for me. I am in Montevideo, Uruguay so I am in UTC/GMT-3 hours. I think that you are 6 hours less.

iranreyes avatar Dec 05 '15 04:12 iranreyes

@gdi2290 , @iranreyes I prepared a todomvc example: https://github.com/fesor/todomvc-angular-components

it has service example (will add store service tonight), stateless components, some tests and so on. I will appreciate any feedback from you.

fesor avatar Jan 04 '16 10:01 fesor

@fesor can you include a link in the readme about it?

PatrickJS avatar Jan 04 '16 17:01 PatrickJS

@gdi2290 when it will be ready. Also I'd like to get as more feedback as possible to make this example more useful.

fesor avatar Jan 04 '16 17:01 fesor

Added link to AngularClass/ng6-todo-starter in readme.

There is example of service and how to test them.

fesor avatar Jan 26 '16 17:01 fesor

@fesor The structure in your todo is different from the NG6-starter. Is there any chance you can write an example with the NG6-starter logic?

yairneumann11 avatar Mar 10 '16 13:03 yairneumann11

@yairneumann11 the only difference is that i don't split all the things into different files (i.e. templates, controllers, components). This shouldn't be a problem, if it is, please ask questions.

I prefer to use inline template to force developers write small templates and make all the things in reusable components.

As for controllers - I just don't see any profit of splitting this up. Event for testing purposes - you can just export it from component module (just like I did). In real-life project you will have a lot of them and have 7 (controller, component definition, template, styles, tests, maybe e2e tests) files just for one component... I'm just to lazy.

fesor avatar Mar 10 '16 17:03 fesor

@fesor, I undertand your preference, but you write an example to people who still learning, like me, and confuses me a lot when I trying understand a logic and in another project with use the same boilerplate is diferent, if you can rewrite the code to follow NG6 pattern, will help a lot new guys like me. This is a diference between encourage and scare newbies.

This is just a feedback from a guy who is learning.

chroda avatar Oct 10 '17 18:10 chroda