@dimas09 wrote:
I have the component
Schedule
and call it like:{{schedule-show currentSupplier=supplier currentVisitor=visitor}}
This component retrives
Events
ofSupplier
and draw this events on the calendar. The component has actions to manipulate with events.I want to encapsulate all business-logic for actions with events in the service
Event
. This service should depends on current supplier, current visitor, current event. The service is singleton so when one of models is changed I need to change it in the service.For example, I need property
canEdit
I to check:
- if the current user is an admin return true OR
- if the current user is a visitor and visitor owns the current event OR
- if the current user is a supplier and supplier owns the current event OR
I have
CurrentUser
service and I can inject it toEvent
service.But how to inject current event to the service in right way?
For example, I need method
create
. To create the event I need pass current state of the form to the service also I need thecurrentSupplier
andcurrentVisitor
. In this case I could pass as arguments of method.The service has finite number of dependencies. What is the right way to inject dependencies like that?
I think in methods I could make in next way:
create(properties) { this.setPropeties(properties); doSomeLogic............. }
For computed properties
property(name, properties) { this.setPropeties(properties); return this.get(name); }
Posts: 1
Participants: 1