-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
11 deletions.
There are no files selected for viewing
18 changes: 7 additions & 11 deletions
18
tests/incremental-json-api/app/services/request-manager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
import { LegacyNetworkHandler } from '@ember-data/legacy-compat'; | ||
import type { Handler, NextFn, RequestContext } from '@ember-data/request'; | ||
import RequestManager from '@ember-data/request'; | ||
import Fetch from '@ember-data/request/fetch'; | ||
// import { CacheHandler } from '@ember-data/store'; | ||
|
||
const TestHandler = { | ||
async request({ request }, next) { | ||
console.log('TestHandler.request', request); | ||
const newContext = await next(Object.assign({}, request)); | ||
/* eslint-disable no-console */ | ||
const TestHandler: Handler = { | ||
async request<T>(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; | ||
return newContext as T; | ||
}, | ||
}; | ||
|
||
export default class Requests extends RequestManager { | ||
constructor(args) { | ||
super(args); | ||
this.use([LegacyNetworkHandler, TestHandler, Fetch]); | ||
|
||
// TODO: This fails due to implementation in Store. It always adds cache. | ||
// Maybe we should change implementation, or just warn about not adding it | ||
|
||
// this.useCache(CacheHandler); | ||
} | ||
} |