diff --git a/guides/cookbook/incremental-adoption-guide.md b/guides/cookbook/incremental-adoption-guide.md index 0c9d6186ba2..13d769b70c9 100644 --- a/guides/cookbook/incremental-adoption-guide.md +++ b/guides/cookbook/incremental-adoption-guide.md @@ -1,10 +1,8 @@ # Incremental adoption guide for existing projects -Nav links +- ⮐ [Cookbook](./index.md) ---- - -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). +This guide is for existing projects that want to adopt the new APIs of the EmberData incrementally. ## Step 1: Upgrade to EmberData 4.12.x @@ -48,11 +46,11 @@ import Fetch from '@ember-data/request/fetch'; /* eslint-disable no-console */ const TestHandler: Handler = { - async request(context: RequestContext, next: NextFn) { + async request(context: RequestContext, next: NextFn) { console.log('TestHandler.request', context.request); - const newContext = await next(Object.assign({}, context.request)); - console.log('TestHandler.response after fetch', newContext.response); - return newContext as T; + const result = await next(Object.assign({}, context.request)); + console.log('TestHandler.response after fetch', result.response); + return result; }, }; @@ -144,3 +142,7 @@ export default class App extends Application { loadInitializers(App, config.modulePrefix); ``` + +--- + +- ⮐ [Cookbook](./index.md) diff --git a/tests/example-json-api/app/services/request-manager.ts b/tests/example-json-api/app/services/request-manager.ts index abfda573909..522664f295e 100644 --- a/tests/example-json-api/app/services/request-manager.ts +++ b/tests/example-json-api/app/services/request-manager.ts @@ -5,11 +5,11 @@ import Fetch from '@ember-data/request/fetch'; /* eslint-disable no-console */ const TestHandler: Handler = { - async request(context: RequestContext, next: NextFn) { + async request(context: RequestContext, next: NextFn) { console.log('TestHandler.request', context.request); - const newContext = await next(Object.assign({}, context.request)); - console.log('TestHandler.response after fetch', newContext.response); - return newContext as T; + const result = await next(Object.assign({}, context.request)); + console.log('TestHandler.response after fetch', result.response); + return result; }, }; diff --git a/tests/example-json-api/app/services/store.js b/tests/example-json-api/app/services/store.js index f7233dd0ac8..d86d966b815 100644 --- a/tests/example-json-api/app/services/store.js +++ b/tests/example-json-api/app/services/store.js @@ -2,9 +2,19 @@ import { service } from '@ember/service'; import Store from 'ember-data/store'; +import { LifetimesService } from '@ember-data/request-utils'; + +import CONFIG from '../config/environment'; + // NOTE: This file must be JS extension as `ember-data` is still v1 addon, // and JS declaration will always "win" in final build of application export default class MyStore extends Store { @service requestManager; + + constructor(args) { + super(args); + + this.lifetimes = new LifetimesService(CONFIG); + } }