-
Notifications
You must be signed in to change notification settings - Fork 0
/
TODO
104 lines (79 loc) · 4.07 KB
/
TODO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
- history back doesnt resolve the routes currently
- @emberx/test-helper tests not runnable on node.js!: routerjs/vendor location-bar prevents the app to be runable on node.js.
// NOTE: @emberx/rsvp: RSVP.defer(); NOTE: probably should just use rsvp npm package.
// NOTE: @emberx/runloop: later, once, next, cancel, debounce, throttle, currentLoop(?) NO, more importantly and a test-waiter system to register test events
glimmer level dom change wait is hooked to global-context on @ember/application
also wraps fetch to implement the similar behavior
- avoid running model hooks
- Avoid running model hooks when redirecting in the middle of another transition.
- Handle two different approaches to transitions:
- 1: url based or with params passed in
- 2: route name with full model object passed in
Ember.Application = boot, register services, reset state, viist, rootElement, unregister, resolver, lookup,
autoboot: false
test-helpers: this.owner
think about error and loading routes
============
API decisions
============
Ember.Router API:
- willTransition()
- didTransition()
- willDestroy()
- location:
- rootURL:
/* transitionTo(name, models, options) */
/* do not use on */
/* this.on('routeDidChange', () => { */
/* this.analytics.trackPage({ page: this.url, title: this.url }); */
/* }); */
/* location description: */
history - use the browser's history API to make the URLs look just like any standard URL
none - do not store the Ember URL in the actual browser URL (mainly used for testing)
Ember.Route API:
- activate: This hook is executed when the router enters the route. It is not executed when the model for the route changes.
- beforeModel (transition) Any | Promise<any>
- model(params, transition) both queryParams and params
- afterModel(resolvedModel, transition) Any | Promise<any>
- deactivate: This hook is executed when the router completely exits this route. It is not executed when the model for the route changes.
- this.modelFor('');
- this.paramsFor('');
- queryParams = {
memberQp: { refreshModel: true }
} /* its not static
- redirect(): aborts current transition
redirect and afterModel behave very similarly and are called almost at the same time, but they have an important distinction
when calling this.transitionTo to a child route of the current route.
From afterModel, this new transition invalidates the current transition, causing beforeModel, model, and afterModel hooks to be called again.
But the same transition started from redirect does not invalidate the current transition.
In other words, by the time the redirect hook has been called, both the resolved model and the attempted entry into this route are considered fully validated.
afterModel and then redirect() gets called
* redirect does not invalidate the current transition, afterModel transitionTo does
- this.refresh() : Transition calls a full refresh(of parent routes)
- replaceWith(name, models, options): Transition will replace the current history entry instead of adding a new one. Same as transitionTo otherwise
- transitionTo (name, models, options) Transition
this.transitionTo('blogComment', aPost, aComment);
this.transitionTo('blogComment', 1, 13);
this.transitionTo('/');
this.transitionTo('/blog/post/1/comment/13');
this.transitionTo('/blog/posts?sort=title');
this.transitionTo('blogPost', 1, {
queryParams: { showComments: 'true' }
});
// if you just want to transition the query parameters without changing the route
this.transitionTo({ queryParams: { sort: 'date' } });
- serialize(model, params) A hook you can implement to convert the route's model into parameters for the URL.
serialize(model) {
// this will make the URL `/posts/12`
return { post_id: model.id };
}
- willDestroy() {
// NOTE: not needed most likely but maybe keep it for router
}
/* there is buildRouteInfoMetadata() to build <head> in future
/* no need for destroy() and isDestroyed prop
/* disconnectOutlet not needed
/* !! intermediateTransitionTo called for error and loading handlers
/* model (params, transition)
/* - this.send() probably not needed
/* resetController/ setupController