Skip to content

Commit e9050cc

Browse files
committed
Fixes after review
1 parent 6a97e6f commit e9050cc

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

guides/cookbook/incremental-adoption-guide.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Incremental adoption guide for existing projects
22

3-
Nav links
3+
-[Cookbook](./index.md)
44

5-
---
6-
7-
This guide is for existing projects that want to adopt the new APIs of the EmberData incrementally. If you are starting a new project, you should use the [new project guide](./new-project-guide.md).
5+
This guide is for existing projects that want to adopt the new APIs of the EmberData incrementally.
86

97
## Step 1: Upgrade to EmberData 4.12.x
108

@@ -48,11 +46,11 @@ import Fetch from '@ember-data/request/fetch';
4846

4947
/* eslint-disable no-console */
5048
const TestHandler: Handler = {
51-
async request<T>(context: RequestContext, next: NextFn) {
49+
async request<T>(context: RequestContext, next: NextFn<T>) {
5250
console.log('TestHandler.request', context.request);
53-
const newContext = await next(Object.assign({}, context.request));
54-
console.log('TestHandler.response after fetch', newContext.response);
55-
return newContext as T;
51+
const result = await next(Object.assign({}, context.request));
52+
console.log('TestHandler.response after fetch', result.response);
53+
return result;
5654
},
5755
};
5856

@@ -144,3 +142,7 @@ export default class App extends Application {
144142

145143
loadInitializers(App, config.modulePrefix);
146144
```
145+
146+
---
147+
148+
-[Cookbook](./index.md)

tests/example-json-api/app/services/request-manager.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import Fetch from '@ember-data/request/fetch';
55

66
/* eslint-disable no-console */
77
const TestHandler: Handler = {
8-
async request<T>(context: RequestContext, next: NextFn) {
8+
async request<T>(context: RequestContext, next: NextFn<T>) {
99
console.log('TestHandler.request', context.request);
10-
const newContext = await next(Object.assign({}, context.request));
11-
console.log('TestHandler.response after fetch', newContext.response);
12-
return newContext as T;
10+
const result = await next(Object.assign({}, context.request));
11+
console.log('TestHandler.response after fetch', result.response);
12+
return result;
1313
},
1414
};
1515

tests/example-json-api/app/services/store.js

+10
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ import { service } from '@ember/service';
22

33
import Store from 'ember-data/store';
44

5+
import { LifetimesService } from '@ember-data/request-utils';
6+
7+
import CONFIG from '../config/environment';
8+
59
// NOTE: This file must be JS extension as `ember-data` is still v1 addon,
610
// and JS declaration will always "win" in final build of application
711

812
export default class MyStore extends Store {
913
@service requestManager;
14+
15+
constructor(args) {
16+
super(args);
17+
18+
this.lifetimes = new LifetimesService(CONFIG);
19+
}
1020
}

0 commit comments

Comments
 (0)