-
Notifications
You must be signed in to change notification settings - Fork 61
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
observe title and titleToken #21
Conversation
travis fails because registry.register is undefined in the router:main tests on canary. all other tests pass |
ok apparently observing currentModel or controller is not supported emberjs/ember.js#9767 this causes transitioning to the same route with a different model to fail if a computed property is used that uses them. volatileCurrentModel: Ember.computed(-> @get 'currentModel').volatile()
titleToken: Ember.computed.alias 'volatileCurrentModel.title' seems to be a viable workaround |
@kimroen any interest in this? if so i could rebase. |
I am very interested in the feature itself, but I have not yet sat down and looked at how good of a solution this is. I still plan to do so, though, so if you have the chance to rebase, I'd appreciate it. Thanks! |
0132e21
to
0d12cad
Compare
|
Could you elaborate on this? I seem to be able to make it work just fine by using title: Ember.computed('controller.model.donations', function() {
return `Donations: ${this.get('controller.model.donations')`;
}) |
var title = get(this.titleRoute, 'title'); | ||
|
||
// a string title just sledgehammer overwrites any children tokens. | ||
// ... Tokens aren't even considered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment doesn't make much sense here.
All right, I've looked through this now, and I have some thoughts: In general, I think the idea and implementation is pretty solid. Instead of collecting the tokens in the bubbling action, you collect the routes, and then loop through them and add observers (etc) once the route with a Observing thingsRight now, the
Computed titlesThis is a new thing with this change, but it seems straight forward enough, I think. The same thing as above goes for this.
|
|
I had a case of paralysis by analysis combined with burnout here. Really sorry about the lack of a response. I've been having some trouble putting words to the issues I have with this binding to the controller, but I believe it comes down to violating the principle of Data Down, Actions Up in Ember—it doesn't feel right. There is probably a good reason the controller is not observable by default, like @mixonic mentioned in his comment. There are some parallels between this change and the query parameters feature in Ember. They were moved to be partly in the controller, but the plan is to move them back to the route once Routable Components are a reality. Some of the problems we are discussing here will have to be tackled in query params as well, so I’m a bit curious as to what the design of that will be. Regarding observing, I agree with your conclusion, but some comments:
To clarify, right now we’re doing a // Ember getter
var titleToken = get(route, 'titleToken');
// Normal property assignment
var titleToken = route.titleToken; I don’t think it’s correct that we couldn’t check, but I still agree that the complexity of setting it up and handling it is probably not worth it. Again, sorry for the delay and lack of actionable feedback here, but I felt it was better to share this incomplete thought than keeping quiet. |
// is not observable. | ||
volatileController: Ember.computed(function() { | ||
return this.get('controller'); | ||
}).volatile() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably not be included in the addon...it's an implementation detail of the consuming application, and it's not the only way a token might change. I don't think the addon itself should provide this.
I'm hesitant to introduce observers, since the message from the core team has generally been to stop using observers if at all possible. Perhaps there is another way? |
I feel edgy about the observers as well, maybe unjustifiably so. One of the most beautiful things about this addon is its simplicity. Serialize app state to title. i am tl;dr; all the details and the usecase for this PR.. so at risk of sounds completely clueless... perhaps this addon can provide a set of helpers and or mixin that allows use to just set Update: |
Has anyone taken a look at https://github.com/tim-evans/ember-page-title ? While the purpose of |
I talked with @tim-evans at EmberConf about merging the two libraries actually. I'm still open to that, it's just not completely clear what that would look like and how one could go about doing it in practice. The two libraries have pretty different ideas of who owns the title of the document, and that difference is significant for how we solve this issue. The problem in this PR is not really how to update the title at all, the sticking point is that the most common use case for observable titles is to depend on the model of the route, and the route doesn't have an observable path to the current model. After the transition is over, the model has been handed over to the controller. In ember-page-title this isn't a problem, because the context of the template is the controller. |
Agreed, @kimroen. I feel that having a bit of guidance as to what the future of Ember's layers will look like may help designing the happiest path forward. It's tough to design something that makes everyone happy, which I think is why we have two solutions at the moment 😅 |
Closing due to outdated. Let us know if 1.0 has any issues! |
allows to update the title without route transition. this solves #9