Skip to content

Commit cbb740c

Browse files
committed
Create cookbook folder in guides
1 parent 175867b commit cbb740c

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

guides/drafts/incremental-adoption-guide.md guides/cookbook/incremental-adoption-guide.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,19 @@ First you need to install [`@ember-data/request`](https://github.com/emberjs/dat
4040

4141
Here is how your own `RequestManager` service may look like:
4242

43-
```js
43+
```ts
44+
import { LegacyNetworkHandler } from '@ember-data/legacy-compat';
45+
import type { Handler, NextFn, RequestContext } from '@ember-data/request';
4446
import RequestManager from '@ember-data/request';
4547
import Fetch from '@ember-data/request/fetch';
46-
import { LegacyNetworkHandler } from '@ember-data/legacy-compat';
47-
48-
const TestHandler = {
49-
async request({ request }, next) {
50-
console.log('TestHandler.request', request);
51-
52-
const newContext = await next(request);
5348

49+
/* eslint-disable no-console */
50+
const TestHandler: Handler = {
51+
async request<T>(context: RequestContext, next: NextFn) {
52+
console.log('TestHandler.request', context.request);
53+
const newContext = await next(Object.assign({}, context.request));
5454
console.log('TestHandler.response after fetch', newContext.response);
55-
56-
return next(newContext);
55+
return newContext as T;
5756
},
5857
};
5958

@@ -103,7 +102,7 @@ Now you can start refactoring old code to use new APIs. You can start with the `
103102
You most likely would need to add Auth Handler to your request manager to add `accessToken` to your requests.
104103
Let's say you have your `accessToken` in the `session` service. Here is how you can add it to the request manager:
105104

106-
```js auth-handler.js
105+
```js
107106
import { inject as service } from '@ember/service';
108107

109108
export default class AuthHandler {

guides/cookbook/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Cookbook
2+
3+
- [Incremental Adoption Guide](./incremental-adoption-guide.md)

guides/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
- [Relationships](./relationships/index.md)
44
- [Requests](./requests/index.md)
55
- [Terminology](./terminology.md)
6+
- [Cookbook](./cookbook/index.md)

0 commit comments

Comments
 (0)