Skip to content

Commit

Permalink
Typing request manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltazore committed Mar 2, 2024
1 parent 095a0d6 commit 18e6a8f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions tests/incremental-json-api/app/services/request-manager.ts
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);
}
}

0 comments on commit 18e6a8f

Please sign in to comment.