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

Router(js) refactor (wip) #16838

Closed
wants to merge 10 commits into from
Closed

Conversation

knownasilya
Copy link
Contributor

@knownasilya knownasilya commented Jul 21, 2018

Putting this here for visibility, this is still a WIP, please don't merge.


Notes from slack:

Nathan Hammond
Couple of thoughts:
- I generally dislike things like `isSetup` because eventually everything has that check on it. I understand why it's there, but it'd be nice not to need it in the future.

Nathan Hammond
The volatile CPs are because you're aliasing properties that are outside of Ember's world. This is actually a use case for observers. Or possibly refactoring router.js to emit something we can watch for.

@knownasilya
Copy link
Contributor Author

Did something that is crashing the tests now.. hum.

@knownasilya
Copy link
Contributor Author

knownasilya commented Jul 21, 2018

Maybe the CPs aren't update since they aren't volatile. Tried get and set, those return errors too.

@knownasilya
Copy link
Contributor Author

knownasilya commented Jul 21, 2018

I'm thinking it has something to do with stubbing/mocking in the tests..

testem.js:1025 Error while processing route: index Cannot read property 'name' of undefined TypeError: Cannot read property 'name' of undefined
    at Class._queryParamsFor (http://localhost:7357/4927/dist/ember.debug.js:36032:63)
    at forEachQueryParam (http://localhost:7357/4927/dist/ember.debug.js:36579:26)
    at Class._deserializeQueryParams (http://localhost:7357/4927/dist/ember.debug.js:35944:7)
    at getFullQueryParams (http://localhost:7357/4927/dist/ember.debug.js:35286:12)
    at getQueryParamsFor (http://localhost:7357/4927/dist/ember.debug.js:35298:27)
    at Class.paramsFor (http://localhost:7357/4927/dist/ember.debug.js:34292:25)
    at Class.deserialize (http://localhost:7357/4927/dist/ember.debug.js:34955:30)
    at applyHook (http://localhost:7357/4927/dist/ember.debug.js:46709:30)
    at UnresolvedHandlerInfoByParam.runSharedModelHook (http://localhost:7357/4927/dist/ember.debug.js:47160:20)
    at UnresolvedHandlerInfoByParam.getModel (http://localhost:7357/4927/dist/ember.debug.js:47385:19)

@jelhan
Copy link
Contributor

jelhan commented Jul 24, 2018

I've fixed the failing tests. I can't make a pull request against your fork. Don't know why, but you can cherry-pick the two commits from here: jelhan@0973652 jelhan@d91bc2a

knownasilya pushed a commit to knownasilya/ember.js that referenced this pull request Jul 24, 2018
@knownasilya
Copy link
Contributor Author

@jelhan 🎆

@@ -197,9 +197,10 @@ const RouterService = Service.extend({
*/
isActive(...args) {
let { routeName, models, queryParams } = extractRouteArgs(args);
let router = this._router;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do let { _isActiveIntent, state } = this._router; and use those instead.

@luxzeitlos
Copy link
Contributor

How is this related to that? Is there still help needed?

@knownasilya
Copy link
Contributor Author

Yes related. Feel free to submit against my fork. Next step would be to create/use public APIs from router.js

@luxzeitlos
Copy link
Contributor

how do you feel about moving to ts?

@knownasilya
Copy link
Contributor Author

knownasilya commented Aug 30, 2018

Moving what to TS? This refactor or router.js?

@chadhietala
Copy link
Contributor

Just giving you a heads up I started adventuring on this journey so that we can implement the rest of emberjs/rfcs#95.

Also related:

Also branch when we realized we needed to push more things down into router.js

@chadhietala
Copy link
Contributor

It would be amazing if someone could use the type declarations from router.js and convert ember-router to TS.

@knownasilya
Copy link
Contributor Author

knownasilya commented Aug 30, 2018

@chadhietala can you explain that last bulleted link and it's context? https://github.com/emberjs/ember.js/commits/route-info

@knownasilya
Copy link
Contributor Author

@chadhietala I've rebased against the changes in master, waiting on travis.

@knownasilya
Copy link
Contributor Author

knownasilya commented Aug 30, 2018

What is you recommendation around using recognizer? Should that be imported explicitly or should the used methods be wrapped in ember router.

For example: router._routerMicrolib.recognizer.handlersFor(routeName);

Also, handlerInfos seems to be a thing that comes from router.js and is used in many places. Is that a public API?

@chadhietala
Copy link
Contributor

Sorry was on holiday. So RouteInfo is a subset of HandlerInfo its going to become public API as described in the RFC.

@knownasilya
Copy link
Contributor Author

@chadhietala any thoughts on route-recognizer? Should that be encapsulated by router.js or should ember use it directly?

@locks
Copy link
Contributor

locks commented Mar 26, 2019

hey @knownasilya, is this work still valid?

@knownasilya
Copy link
Contributor Author

I don't think so. Other people tackled refactors at the same time that it would take a while to unwind.

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

Successfully merging this pull request may close these issues.

None yet

6 participants