Accessing the controller / services
See original GitHub issueWould it hurt, if we were able to access the corresponding Controller
from the serialize
and deserialize
methods?
I am asking primarily because I need to synchronously access the store
service, in order to lookup a record for an ID. Basically something like this:
new QueryParams({
someModel: {
defaultValue: null,
serialize(model) {
return model ? get(model, 'id') : '';
},
deserialize(id) {
return id ? get(this, 'store').peekRecord('model-name', id) : null;
}
});
Do you think this is a form of unhealthy entanglement, even though the lookup is guaranteed to work synchronously?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:17 (6 by maintainers)
Top Results From Across the Web
Dependency injection into controllers in ASP.NET Core
Services are typically defined using interfaces. ... Accessing app or configuration settings from within a controller is a common pattern.
Read more >Various ways of accessing DI services
Constructor injection is possibly the most common way of accessing the DI services inside a controller. As the name suggests, constructor ...
Read more >Chapter 5. Understanding controllers and services - Griffon in ...
Simply put, controllers have the responsibility to react to inputs, usually coming from the UI.
Read more >Accessing Service Layer from Controller in MVC Project
I'm now trying to relocate all business logic to a Services project that contains a bunch of classes. To start I added a...
Read more >Configure the controller services | CDP Public Cloud
To add a Controller Service to your flow, right-click on the Canvas and select Configure from the pop-up menu. · Select the Controller...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@roberkules I’m going to try an aproach today using a computed property which is the actual records array with the url parameters just being an array of ids, when that array updates the computed property should recompute a corresponding array.
@offirgolan @buschtoens would you say that sounds like a reasonable way to implement this functionality?
edit: turns out I didn’t need a computed property at all.
In the
setup()
hook I addedThen I’m using an ember-power-select component to modify the array, instead of just doing
onchange=(action (mut selectedQualifications))
I used an actions to modify both propertiesMy query parameter maps to
chosenQualificationIds
I’ve had that thought before.
As @offirgolan says It’s definitely possible, although I would pass the controller in as an argument rather than have the context of those functions be rebound. I think having
this
in the serialize or derserialize functions be the controller would be slightly confusing